コード例 #1
0
    //attempt to attach controllers to players
    public void AttachControllers()
    {
        // if count, assign controllers

        /* if (Gamepad.all.Count >= players.Count)
         * {
         *  for (int a = 0; a < players.Count; a++)
         *  {
         *      Debug.Log("players: " + players[a].name);
         *      players[a].GetComponent<Movement2D_Base>().AssignController(Gamepad.all[a]);
         *      //players[a].ActivatePlayer(Gamepad.all[a], a);
         *  }
         * }
         * else */
        for (int i = 0; i < players.Count; i++)
        {
            Movement2D_Base ctrl = players[i].GetComponent <Movement2D_Base>();
            if (i < Gamepad.all.Count)
            {
                Debug.Log("Ctrl: " + ctrl.name);
                Debug.Log("GameControls: " + _GameControls.All.name);
                ctrl.AssignController(_GameControls.All.GetGamePad(i));
            }
            else
            {
                ctrl.is_keyboard = true;
                ctrl.keyboard_id = i + 1;
            }
        }
    }