/// <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(bool isFirstPlayer) { // 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 (isFirstPlayer) { controls.MakePrivateCopyOfActions(); } // 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> /// <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() { Debug.Assert(uiActions != null); Debug.Assert(projectilePrefab != null); Debug.Assert(controls != null); // Each player gets a separate action setup. This makes the state of actions and bindings // local to each player and also ensures we're not stepping on the action setup used by // DemoGame itself for the main menu (where we are not using control schemes and just blindly // bind to whatever devices are available locally). controls.MakePrivateCopyOfActions(); // 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); // 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. uiActions.BindUIActions(controls.menu); }