RootControllerManager
This class manages UI control for controller-based interaction in the game. It handles hotbar visibility, injected UI overlays, tab switching, and contextual interaction prompts. It serves as the central controller interface for player interactions and dynamic UI elements.
public class RootControllerManager : MonoBehaviour
๐ฎ Key Responsibilitiesโ
- Controller Tab Management: Switches between different controller UI tabs like Chat, Build, Emote, Hotbar, and Settings.
- UI Injection System: Allows temporary injection of custom UI, such as modals or menus.
- Interaction Prompt Handling: Displays input button prompts when the player is near interactable objects.
- Multiplayer Actor Integration: Monitors spawned/despawned actors and ties into their interaction events.
๐งฉ Dependenciesโ
UIVisibilityController,AnimatedVisibilityComponentโ manages visibility transitions.ContextualInteractionPrompt,InteractionListProvider,PopupMessageProviderโ control user-facing prompts.PlayerActorโ each player's interaction state is tied to this.
๐ Controller Tabsโ
Enum: ControllerTab
Controls which UI view is active:
None: No tab active.Hotbar,Chat,Emote,Build,Settings: Activates respective UI panels.
ChangeTab(ControllerTab newTab)โ
Switches active UI tab. Also toggles hotbar, joystick, and directional buttons visibility.
๐ Injected UI Systemโ
Dynamically loads custom UI panels and blocks player input when active.
ShowInjectedUI(...)โ
Instantiates and shows a new UI panel, optionally blocking other UI interactions.
ReleaseInjectedUI(...)โ
Destroys the current injected UI and returns to a default tab.
๐ง Actor Interaction Logicโ
- Tracks active
PlayerActorinstances. - Updates input prompts based on
InteractionOptionsChangedcallback. - Provides
ShowInteractionList()to display full interaction menus.
๐ฌ Interaction Promptsโ
Dynamically creates prompts to indicate which buttons trigger what actions.
InteractionOptionsChanged(Dictionary<InputButton, string>)โ
Destroys and recreates prompts for all available input interactions.
๐ฆ UI Injection Interfaceโ
public interface IRootControllerUIProvider
{
Task<GameObject> GetUIPrefab();
void ReleaseUIPrefab();
}
Use this to inject UI that interacts with the root controller system, such as modals, inventory, or quest windows.
๐งช Singleton Accessโ
Static property:
public static RootControllerManager Local;
Provides global access to the current instance.
๐ฒ Credits UIโ
Text field creditLabel is updated when the user's profile changes via OnUserDetailsChanged().
๐งผ Cleanupโ
Properly disconnects from all events and disposes of any dynamic UI or input bindings during OnDisable() and OnDestroy().
โ Example Use Casesโ
-
Switch to Build tab:
RootControllerManager.Local.ChangeTabWrapper_Build(); -
Show modal and block interactions:
RootControllerManager.Local.ShowInjectedUI(provider, null, true); -
Display button prompt for
ButtonSouth:
Shown automatically via interaction events.