Kanda Players 0.7.0
All Classes Namespaces Functions Variables Enumerations Properties Pages
Menu

In-session Menu is the menu that can be toggled on/off by the player during the runtime in a session. The In-session Menu usually consists of couple of functionalities that the player can trigger, as well as the player current status. Some settings are also be included in the menu.

In-session Menu Lifecycle

In-session Menu only lives in a specific scenario within a session. When the player moves to another scene, the In-session Menu will also be removed (toggled off). The player cannot see the UI canvas of other player's menu, this is because the UI canvas is not synched between players.

Toggling In-session Menu

  1. PC
    • Press Menu button (ESC) to toggle it On/Off
  2. VR
    • Press Secondary Button in the controller to toggle it On/Off for both left/right hands.

Pressing button will only toggle on/off the menu that the player spawned themselves.

But for VR, the hand can toggle off the menu that is spawned by the other hand by the same player.

In-session Menu Components

  • InSessionMenu: A tag for the In-session Menu entity itself.
  • InSessionMenuSpawner: Holds the menu prefab and position and rotation offsets.
  • ToggleInSessionMenuCommand: An RPC command to be sent to server to spawn/destroy In-session menu.

Toggling Logic Flow

  1. Get the input from PC/VR in InSessionMenuToggleClientSystem.
  2. Check if the menu for the player's PlayerInfo already exists in the world. If it is, the ToggleInSessionMenuCommand should have ShouldDestroy set to true.
  3. Send RPC command to the server for ToggleInSessionMenuCommand.
  4. In the server, we're getting the RPC command ToggleInSessionMenuCommand in InSessionMenuToggleServerSystem.
  5. Based on ToggleInSessionMenuCommand.ShouldDestroy, spawn or destroy the menu entity.
  6. For spawning, check again for the same menu entity with the same PlayerInfo to avoid double spawning the same menu.
  7. After the menu entity is spawned, the Menu Canvas is spawned from InSessionMenu.MenuCanvasPrefab for the local player only and skipping the other player's canvas.