예제 #1
0
    void Awake()
    {
        // Singleton
        if (instance == null)
        {
            instance = this;
        }
        else if (!instance.Equals(this))
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        // Finds the first connected xbox 360 controller
#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
        playerIndexSet = false;
        for (int i = 0; i < 4; ++i)
        {
            PlayerIndex  testPlayerIndex = (PlayerIndex)i;
            GamePadState testState       = GamePad.GetState(testPlayerIndex);
            if (testState.IsConnected)
            {
                Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                if (!playerIndexSet)
                {
                    playerIndex    = testPlayerIndex;
                    playerIndexSet = true;
                }
            }
        }
#endif

        // Initialize OS X controller states
#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
        OSXJoystickPreviousState = new Dictionary <string, bool>();
        OSXJoystickState         = new Dictionary <string, bool>();
#endif
    }
예제 #2
0
 void Awake()
 {
     inputManager    = CommonInputManager.instance;
     cameraReference = GameObject.FindWithTag("MainCamera");
     rb = GetComponent <Rigidbody>();
 }