void Start()
        {
            int i;

            numAxes   = i = axes.Length;
            _aHandles = new CrossPlatformInputManager.VirtualAxis[numAxes];
            for (i = 0; i < numAxes; ++i)
            {
                _aHandles[i] = CrossPlatformInputManager.VirtualAxisReference(this, axes[i], true);
            }

            numButtons = i = buttons.Length;
            _bHandles  = new CrossPlatformInputManager.VirtualButton[i];
            for (i = 0; i < numButtons; ++i)
            {
                _bHandles[i] = CrossPlatformInputManager.VirtualButtonReference(this, buttons[i], true);
            }
            m_ButtonsPrev = m_Buttons = 0;

            /*-----Joystick CallBack Mode .Android Platform-----*/
#if !UNITY_EDITOR && UNITY_ANDROID
            AndroidJavaClass       player       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject      activity     = player.GetStatic <AndroidJavaObject>("currentActivity");
            CInputListenerCallBack AdListenerCB = new CInputListenerCallBack();
            activity.CallStatic("SetListenerCB", AdListenerCB);
#endif
        }
        public virtual int InitInput()
        {
            // Check number of virtual elements.
            if (numAxes < 0)
            {
                numAxes = axes.Length;
            }
            if (numButtons < 0)
            {
                numButtons = buttons.Length;
            }
            // Register virtual elements.
            mapInput = new Dictionary <string, EntryString>(numAxes + numButtons);
            int i;

            // VirtualAxis
            _aHandles = new CrossPlatformInputManager.VirtualAxis[numAxes];
            for (i = 0; i < numAxes; ++i)
            {
                CrossPlatformInputManager.VirtualAxis va = null;

                //va = CrossPlatformInputManager.VirtualAxisReference(axes[i].key);
                va           = CrossPlatformInputManager.VirtualAxisReference(this, axes[i].key, true);
                _aHandles[i] = va;
                mapInput.Add(axes[i].key, axes[i]);
            }
            // VirtualButton
            _bHandles = new CrossPlatformInputManager.VirtualButton[numButtons];
            for (i = 0; i < numButtons; ++i)
            {
                _bHandles[i] = CrossPlatformInputManager.VirtualButtonReference(this, buttons[i].key, true);
                mapInput.Add(buttons[i].key, buttons[i]);
            }
            return(0);
        }
Beispiel #3
0
 private void ResetButton(ref CrossPlatformInputManager.VirtualButton button, string buttonName)
 {
     if (!CrossPlatformInputManager.ButtonExists(buttonName))
     {
         button = new CrossPlatformInputManager.VirtualButton(buttonName);
         CrossPlatformInputManager.RegisterVirtualButton(button);
     }
     else
     {
         button = CrossPlatformInputManager.VirtualButtonReference(buttonName);
     }
 }
        void Start()
        {
            int i;

            numAxes   = i = axes.Length;
            _aHandles = new CrossPlatformInputManager.VirtualAxis[numAxes];
            for (i = 0; i < numAxes; ++i)
            {
                _aHandles[i] = CrossPlatformInputManager.VirtualAxisReference(this, axes[i], true);
            }

            numButtons = i = buttons.Length;
            _bHandles  = new CrossPlatformInputManager.VirtualButton[i];
            for (i = 0; i < numButtons; ++i)
            {
                _bHandles[i] = CrossPlatformInputManager.VirtualButtonReference(this, buttons[i], true);
            }
            m_ButtonsPrev = m_Buttons = 0;
        }