/// <summary> /// One-time initialization for a player controller. /// </summary> /// <remarks> /// Once spawned, we are reusing player instances over and over. The setup we perform in here, /// however, is done only once. /// </remarks> public void PerformOneTimeInitialization(int playerIndex) { // Each player gets a separate action setup. The first player simply uses // the actions as is but for any additional player, we need to duplicate // the original actions. if (playerIndex != 0) { controls.DuplicateAndSwitchAsset(); } // Wire our callbacks into gameplay actions. We don't need to do the same // for menu actions as it's the UI using those and not us. controls.gameplay.SetCallbacks(this); ////REVIEW: we have to figure out who controls the enabling/disabling of actions used by UIs // Wire our input actions into the UI. Doing this manually here instead of setting it up // in the inspector ensure that when we duplicate DemoControls.inputactions above, we // end up with the UI using the right actions. // // NOTE: Our bindings will be effective on the devices assigned to the user which in turn // means that the UI will react only to input from that same user. var uiInput = ui.GetComponent <UIActionInputModule>(); Debug.Assert(uiInput != null); uiInput.move = new InputActionProperty(controls.menu.navigate); uiInput.leftClick = new InputActionProperty(controls.menu.click); }
/// <summary> /// One-time initialization for a player controller. /// </summary> public void Initialize(int playerIndex) { // Each player gets a separate action setup. The first player simply uses // the actions as is but for any additional player, we need to duplicate // the original actions. if (playerIndex != 0) { controls.DuplicateAndSwitchAsset(); } // Wire our input actions into the UI. Doing this manually here instead of setting it up // in the inspector ensure that when we duplicate DemoControls.inputactions above, we // end up with the UI using the right actions. // // NOTE: Our bindings will be effective on the devices assigned to the user which in turn // means that the UI will react only to input from that same user. var uiInput = ui.GetComponent <UIActionInputModule>(); Debug.Assert(uiInput != null); uiInput.move = new InputActionProperty(controls.menu.navigate); uiInput.leftClick = new InputActionProperty(controls.menu.click); }