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
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
    private CrossPlatformInputManager.VirtualAxis axis;     // A reference to the virtual axis as it is in the cross platform input

    void OnEnable()
    {
        // if the axis doesnt exist create a new one in cross platform input
        axis = CrossPlatformInputManager.VirtualAxisReference(axisName) ?? new CrossPlatformInputManager.VirtualAxis(axisName);

        FindPairedButton();
    }
Esempio n. 4
0
 void CreateVirtualAxes()
 {
     if (moveController)
     {
         if (!CrossPlatformInputManager.AxisExists(horizontalAxisName))
         {
             m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
             CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
             m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName);
             CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
         }
         else
         {
             m_HorizontalVirtualAxis = CrossPlatformInputManager.VirtualAxisReference(horizontalAxisName);
             m_VerticalVirtualAxis   = CrossPlatformInputManager.VirtualAxisReference(verticalAxisName);
         }
     }
     else
     {
         if (!CrossPlatformInputManager.AxisExists(horizontalAxisNameLook))
         {
             m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisNameLook);
             CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
             m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisNameLook);
             CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
         }
         else
         {
             m_HorizontalVirtualAxis = CrossPlatformInputManager.VirtualAxisReference(horizontalAxisNameLook);
             m_VerticalVirtualAxis   = CrossPlatformInputManager.VirtualAxisReference(verticalAxisNameLook);
         }
     }
 }
Esempio n. 5
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        _gameManager?.BoostButton.onClick.AddListener(Boost);

        // The axes are based on player number.
        m_MovementAxis = "Vertical";
        m_TurnAxis     = "Horizontal";
        // Store the original pitch of the audio source.
        m_OriginalPitch = m_MovementAudio.pitch;

        if (CrossPlatformInputManager.AxisExists(m_MovementAxis))
        {
            mobile_MovementAxis = CrossPlatformInputManager.VirtualAxisReference(m_MovementAxis);
        }
        if (CrossPlatformInputManager.AxisExists(m_TurnAxis))
        {
            mobile_TurnAxis = CrossPlatformInputManager.VirtualAxisReference(m_TurnAxis);
        }
        //This gets the Main Camera from the Scene
        m_MainCamera = Camera.main;

        m_MainCamera.GetComponent <SmoothFollow>().Init(transform);
    }
    //IEnumerator regenStamina()
    //{
    //    while(true)
    //    {
    //        yield return new WaitForSeconds(0.25f);
    //        if (stamina < maxStamina)
    //        {
    //            if (isBlocking)
    //            {
    //                stamina += baseStaBlockRegen* 0.25f;
    //            }
    //            else
    //            {
    //                stamina += baseStaRegen;
    //            }
    //            updateStamina();
    //        }
    //        if (stamina <= 0)
    //        {
    //            performUnBlock();
    //            stamina = 0;
    //        }
    //        if (stamina >= maxStamina)
    //        {
    //            stamina = maxStamina;
    //        }
    //    }
    //}

    void FixedUpdate()
    {
        if (id != -1)
        {
            x = CrossPlatformInputManager.VirtualAxisReference("Horizontal_" + id).GetValue;
            y = CrossPlatformInputManager.VirtualAxisReference("Vertical_" + id).GetValue;
            if (!isAtk && !isBlocking)
            {
                if ((x != 0.00f || y != 0.00f) && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack01") && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack02"))
                {
                    transform.Translate(Vector3.forward * speed * Time.deltaTime);
                    anim.SetInteger("Speed", 2);
                }
                else if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack01") && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack02"))
                {
                    anim.SetInteger("Speed", -1);
                }
            }
            if ((x != 0.00f || y != 0.00f))
            {
                angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45 + 90;
                //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);
                if (angle < 0)
                {
                    angle += 360;
                }
                transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);
            }
            if (stamina < maxStamina && chargState == 0)
            {
                if (isBlocking)
                {
                    stamina += baseStaBlockRegen * Time.deltaTime;
                }
                else
                {
                    stamina += baseStaRegen * Time.deltaTime;
                }
                updateStamina();
            }
            else if (chargState > 0)
            {
                stamina -= chargState * Time.deltaTime;
                updateStamina();
            }
            if (stamina <= 0)
            {
                performUnBlock();
                stamina = 0;
            }
            if (stamina > maxStamina)
            {
                stamina = maxStamina;
            }
        }
    }
Esempio n. 7
0
 private CrossPlatformInputManager.VirtualAxis getAxisOrCreate(string name)
 {
     CrossPlatformInputManager.VirtualAxis axis = CrossPlatformInputManager.VirtualAxisReference(name);
     if (axis == null)
     {
         axis = new CrossPlatformInputManager.VirtualAxis(name);
         CrossPlatformInputManager.RegisterVirtualAxis(axis);
     }
     return(axis);
 }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (id != -1)
        {
            x = CrossPlatformInputManager.VirtualAxisReference("Horizontal_" + id).GetValue;
            y = CrossPlatformInputManager.VirtualAxisReference("Vertical_" + id).GetValue;

            if (!isDeath)
            {
                if (myState != State.RUSH)
                {
                    if (x != 0.00f || y != 0.00f)
                    {
                        if (myState != State.ATK)
                        {
                            transform.Translate(mainBody.forward * statContol.speedCurrent * Time.deltaTime);
                        }
                        //  anim.SetInteger("Speed", 2);
                        angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45;
                        //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);
                        if (angle < 0)
                        {
                            angle += 360;
                        }
                        mainBody.rotation = Quaternion.Lerp(mainBody.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);
                    }
                    else
                    {
                        anim.SetInteger("Speed", -1);
                    }
                }
                else
                {
                    angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45;
                    if (ultimateManager.isUltimating)
                    {
                        ultiPointer.rotation = Quaternion.Lerp(ultiPointer.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);
                        //mainBody.rotation = Quaternion.Lerp(mainBody.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed * 0.01f);
                        //transform.Translate(mainBody.forward * statContol.speedCurrent * Time.deltaTime * (ultiSpeedFactor + 0.2f));
                    }
                    else
                    {
                        mainBody.rotation = Quaternion.Lerp(mainBody.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed * rushTrunSpeedMutiply);
                    }
                    transform.Translate(mainBody.forward * statContol.speedCurrent * Time.deltaTime * (1f + RushspeedUpfactor));
                    // else
                    // {


                    // }
                }
            }
        }
    }
Esempio n. 9
0
 /// <summary>
 /// Добавляем управление
 /// </summary>
 /// <param name="axisName"></param>
 /// <param name="m_Axis"></param>
 private void AddControl(string axisName, out CrossPlatformInputManager.VirtualAxis m_Axis)
 {
     if (!CrossPlatformInputManager.AxisExists(axisName))
     {
         m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);
         CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
     }
     else
     {
         m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
 }
Esempio n. 10
0
 private void RegisterVirtualAxis()
 {
     if (!CrossPlatformInputManager.AxisExists(axisName))
     {
         virtualAxis = new CrossPlatformInputManager.VirtualAxis(axisName);
         CrossPlatformInputManager.RegisterVirtualAxis(virtualAxis);
     }
     else
     {
         virtualAxis = CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
 }
Esempio n. 11
0
 private void CreateVirtualAxis()
 {
     if (!CrossPlatformInputManager.AxisExists(axisName))
     {
         // if the axis doesnt exist create a new one in cross platform input
         horizontalAxis = new CrossPlatformInputManager.VirtualAxis(axisName);
         CrossPlatformInputManager.RegisterVirtualAxis(horizontalAxis);
     }
     else
     {
         horizontalAxis = CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
 }
Esempio n. 12
0
 private void ResetAxis(ref CrossPlatformInputManager.VirtualAxis axis, string axisName)
 {
     if (!CrossPlatformInputManager.AxisExists(axisName))
     {
         // if the axis doesnt exist create a new one in cross platform input
         axis = new CrossPlatformInputManager.VirtualAxis(axisName, false);
         CrossPlatformInputManager.RegisterVirtualAxis(axis);
     }
     else
     {
         axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (horizontal != null && vertical != null)
     {
         horizontal.Update(Input.GetAxis("Horizontal"));
         vertical.Update(Input.GetAxis("Vertical"));
     }
     else
     {
         horizontal = CrossPlatformInputManager.VirtualAxisReference("Horizontal");
         vertical   = CrossPlatformInputManager.VirtualAxisReference("Vertical");
     }
 }
    CrossPlatformInputManager.VirtualAxis m_Axis;    // A reference to the virtual axis as it is in the cross platform input

    void OnEnable()
    {
        if (!CrossPlatformInputManager.AxisExists(axisName))
        {
            // if the axis doesnt exist create a new one in cross platform input
            m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);
            CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
        }
        else
        {
            m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
        }
        FindPairedButton();
    }
Esempio n. 15
0
        private void PollInput()
        {
            _joystickPosition.x = CrossPlatformInputManager.VirtualAxisReference("Vertical").GetValue;
            _joystickPosition.y = CrossPlatformInputManager.VirtualAxisReference("Horizontal").GetValue * -1f;

            if (CrossPlatformInputManager.GetButtonDown("Fire1") || CrossPlatformInputManager.GetButton("Fire1"))
            {
                _isFiring1 = true;
            }

            if (CrossPlatformInputManager.GetButtonUp("Fire1"))
            {
                _isFiring1 = false;
            }
        }
Esempio n. 16
0
    // Update is called once per frame
    void Update()
    {
        if (id != -1)
        {
            x = CrossPlatformInputManager.VirtualAxisReference("Horizontal_" + id).GetValue;
            y = CrossPlatformInputManager.VirtualAxisReference("Vertical_" + id).GetValue;

            if (!isDeath)
            {
                if ((x != 0.00f || y != 0.00f) && !isAbnormalState())
                {
                    if (!isCast)
                    {
                        anim.SetInteger("Speed", RUN);
                    }
                    else
                    {
                        anim.SetInteger("Speed", WALK);
                        if (wizardAnimAvatar.gameObject.activeInHierarchy)
                        {
                            wizardAnimAvatar.SetInteger("Speed", WALK);
                        }
                    }
                    transform.Translate(Vector3.forward * speedReal * Time.deltaTime);

                    angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45;
                    //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);
                    if (angle < 0)
                    {
                        angle += 360;
                    }
                    transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);
                }
                else if (isAbnormalState())
                {
                }
                else
                {
                    anim.SetInteger("Speed", IDLE);
                    myRigibody.velocity = Vector3.zero;
                    if (wizardAnimAvatar.gameObject.activeInHierarchy)
                    {
                        wizardAnimAvatar.SetInteger("Speed", IDLE);
                    }
                }
            }
        }
    }
        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;
        }
Esempio n. 18
0
    private void getMoveInput(ref float h, ref float v)
    {
#if MOBILE_INPUT
        CrossPlatformInputManager.VirtualAxis virX = CrossPlatformInputManager.VirtualAxisReference("Virtual_X");
        CrossPlatformInputManager.VirtualAxis virY = CrossPlatformInputManager.VirtualAxisReference("Virtual_Y");
        h = virX.GetValue;
        v = virY.GetValue;
#else
        h = CrossPlatformInputManager.GetAxis("Horizontal");
        v = CrossPlatformInputManager.GetAxis("Vertical");

        if (Globe.virtualButton)
        {
            if (h == 0 && v == 0)
            {
                CrossPlatformInputManager.VirtualAxis virX = CrossPlatformInputManager.VirtualAxisReference("Virtual_X");
                CrossPlatformInputManager.VirtualAxis virY = CrossPlatformInputManager.VirtualAxisReference("Virtual_Y");
                h = virX.GetValue;
                v = virY.GetValue;
            }
        }
#endif
    }
Esempio n. 19
0
    //If this rig is enabled we will register the two virtual axis with the CrossPlatformInputManager. This means these axis values will be derived from this script.
    private void OnEnable()
    {
        //TODO this can probably be tidied up
        if (!CrossPlatformInputManager.AxisExists("Vertical"))
        {
            verticalAxis = new CrossPlatformInputManager.VirtualAxis("Vertical");
            CrossPlatformInputManager.RegisterVirtualAxis(verticalAxis);
        }
        else
        {
            verticalAxis = CrossPlatformInputManager.VirtualAxisReference("Vertical");
        }

        if (!CrossPlatformInputManager.AxisExists("Horizontal"))
        {
            horizontalAxis = new CrossPlatformInputManager.VirtualAxis("Horizontal");
            CrossPlatformInputManager.RegisterVirtualAxis(horizontalAxis);
        }
        else
        {
            horizontalAxis = CrossPlatformInputManager.VirtualAxisReference("Horizontal");
        }
    }
Esempio n. 20
0
    // Update is called once per frame
    void Update()
    {
        if (id != -1)
        {
            x = CrossPlatformInputManager.VirtualAxisReference("Horizontal_" + id).GetValue;
            y = CrossPlatformInputManager.VirtualAxisReference("Vertical_" + id).GetValue;

            if (!isDeath)
            {
                if ((x != 0.00f || y != 0.00f) && !isShooting && !isDodge && !isUltimate)
                {
                    if (anim.speed != 1)
                    {
                        anim.speed = 1;
                    }
                    //if (!isDrawBow)
                    //{
                    if (!isDrawBow)
                    {
                        transform.Translate(Vector3.forward * statContol.speedCurrent * Time.deltaTime);
                    }
                    else
                    {
                        transform.Translate(Vector3.forward * statContol.speedCurrent * Time.deltaTime * 0.4f);
                    }
                    // anim.SetInteger("Speed", RUN);
                    setRun();
                    angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45;
                    //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);
                    if (angle < 0)
                    {
                        angle += 360;
                    }

                    transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);

                    //}
                    //else if(isDrawBow)
                    //{
                    //    angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg)-45;
                    //    //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);
                    //    if (angle < 0) angle += 360;
                    //    //Debug.Log(angle);
                    //    transform.Translate(Quaternion.Euler(0, 495 - angle - 180, 0) * new Vector3(1,0,0) * statContol.speedCurrent * Time.deltaTime*0.35f);
                    //    // anim.SetInteger("Speed", RUN);
                    //    setRun();
                    //}
                }

                else if (isShooting || isDrawBow || isDodge || isUltimate)
                {
                    if (isDodge)
                    {
                        if (anim.speed != 1)
                        {
                            anim.speed = 1;
                        }
                        transform.Translate(Vector3.forward * dodgeSpeed * Time.deltaTime);
                    }
                }
                else
                {
                    anim.SetInteger("Speed", IDLE);
                    if (anim.speed != 1)
                    {
                        anim.speed = 1;
                    }
                    myRigibody.velocity = Vector3.zero;
                }
            }
        }
    }
Esempio n. 21
0
    void FixedUpdate()
    {
        if (id != -1)
        {
            x = CrossPlatformInputManager.VirtualAxisReference("Horizontal_" + id).GetValue;
            y = CrossPlatformInputManager.VirtualAxisReference("Vertical_" + id).GetValue;
            if (!isDeath)
            {
                if (!isAtk && !isPrefromUlti)
                {
                    if ((x != 0.00f || y != 0.00f) && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack01") && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack02"))
                    {
                        if (!isBlocking)
                        {
                            transform.Translate(Vector3.forward * statContol.speedCurrent * Time.deltaTime);
                        }
                        else
                        {
                            transform.Translate(Vector3.forward * statContol.speedCurrent * Time.deltaTime * walkSpeed);
                        }
                        //anim.SetInteger("Speed", 2);
                        anim.SetBool("isRunning", true);
                    }
                    else if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack01") && !anim.GetCurrentAnimatorStateInfo(0).IsName("Attack02"))
                    {
                        //anim.SetInteger("Speed", -1);
                        anim.SetBool("isRunning", false);
                        myRigibody.velocity = Vector3.zero;

                        /* if (isCharging && isCharged)
                         * {
                         *   StartCoroutine(chargeDelay());
                         * }*/
                    }
                }

                if ((x != 0.00f || y != 0.00f) && !isPrefromUlti)
                {
                    angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) - 45;
                    //Debug.Log("x:" + x + "|y:" + y + "|angle:" + angle);

                    if (angle < 0)
                    {
                        angle += 360;
                    }
                    transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 495 - angle - 180, 0), Time.deltaTime * turnspeed);
                }
                if (stamina < maxStamina && chargState == 0)
                {
                    if (isBlocking)
                    {
                        stamina += baseStaBlockRegen * Time.deltaTime;
                    }
                    else
                    {
                        stamina += baseStaRegen * Time.deltaTime;
                    }
                    updateStamina();
                }

                /* else if (chargState > 0)
                 * {
                 *   stamina -= chargState * Time.deltaTime;
                 *   updateStamina();
                 * }*/
                if (stamina <= 0)
                {
                    performUnBlock();
                    stamina = 0;
                }
                if (stamina > maxStamina)
                {
                    stamina = maxStamina;
                }
            }
        }
    }
        void OnEnable()
        {
            // Get power component
            powerJoystick = GetComponent <PowerJoystick> ();
            powerDPad     = GetComponent <PowerDPad> ();
            powerButton   = GetComponent <PowerButton> ();
            if (powerJoystick != null)
            {
                powerType = PowerType.Joystick;
            }
            else if (powerDPad != null)
            {
                powerType = PowerType.DPad;
            }
            else if (powerButton != null)
            {
                powerType = PowerType.Button;
            }

            // Subscribe to trigger events
            if (powerType == PowerType.Joystick)
            {
                PowerJoystick.OnJoyPosHTriggerButtonDown += PosHTriggerButtonDown;
                PowerJoystick.OnJoyPosHTriggerButtonUp   += PosHTriggerButtonUp;
                PowerJoystick.OnJoyNegHTriggerButtonDown += NegHTriggerButtonDown;
                PowerJoystick.OnJoyNegHTriggerButtonUp   += NegHTriggerButtonUp;
                PowerJoystick.OnJoyPosVTriggerButtonDown += PosVTriggerButtonDown;
                PowerJoystick.OnJoyPosVTriggerButtonUp   += PosVTriggerButtonUp;
                PowerJoystick.OnJoyNegVTriggerButtonDown += NegVTriggerButtonDown;
                PowerJoystick.OnJoyNegVTriggerButtonUp   += NegVTriggerButtonUp;
            }
            if (powerType == PowerType.DPad)
            {
                PowerDPad.OnDPadPosHTriggerButtonDown += PosHTriggerButtonDown;
                PowerDPad.OnDPadPosHTriggerButtonUp   += PosHTriggerButtonUp;
                PowerDPad.OnDPadNegHTriggerButtonDown += NegHTriggerButtonDown;
                PowerDPad.OnDPadNegHTriggerButtonUp   += NegHTriggerButtonUp;
                PowerDPad.OnDPadPosVTriggerButtonDown += PosVTriggerButtonDown;
                PowerDPad.OnDPadPosVTriggerButtonUp   += PosVTriggerButtonUp;
                PowerDPad.OnDPadNegVTriggerButtonDown += NegVTriggerButtonDown;
                PowerDPad.OnDPadNegVTriggerButtonUp   += NegVTriggerButtonUp;
            }
            // Subscribe to normal button events
            if (powerType == PowerType.Button)
            {
                PowerButton.OnPowerButtonDown += OnPowerButtonDown;
                PowerButton.OnPowerButtonUp   += OnPowerButtonUp;
            }

            // Register joystick axis
            if (powerType == PowerType.Joystick)
            {
                if (powerJoystick.useAxis == PowerJoystick.UseAxis.Both || powerJoystick.useAxis == PowerJoystick.UseAxis.Horizontal)
                {
                    if (powerJoystick.GetHorizontalAxisName() != "" && !CrossPlatformInputManager.AxisExists(powerJoystick.GetHorizontalAxisName()))
                    {
                        horizontalAxis = new CrossPlatformInputManager.VirtualAxis(powerJoystick.GetHorizontalAxisName());
                        CrossPlatformInputManager.RegisterVirtualAxis(horizontalAxis);
                    }
                    // Unregister doesn't work correctly / Get axis reference (necessary if joysticks gets disbled and enabled again)
                    if (powerJoystick.GetHorizontalAxisName() != "" && CrossPlatformInputManager.AxisExists(powerJoystick.GetHorizontalAxisName()))
                    {
                        horizontalAxis = CrossPlatformInputManager.VirtualAxisReference(powerJoystick.GetHorizontalAxisName());
                    }
                }
                if (powerJoystick.useAxis == PowerJoystick.UseAxis.Both || powerJoystick.useAxis == PowerJoystick.UseAxis.Vertical)
                {
                    if (powerJoystick.GetVerticalAxisName() != "" && !CrossPlatformInputManager.AxisExists(powerJoystick.GetVerticalAxisName()))
                    {
                        verticalAxis = new CrossPlatformInputManager.VirtualAxis(powerJoystick.GetVerticalAxisName());
                        CrossPlatformInputManager.RegisterVirtualAxis(verticalAxis);
                    }
                    // Unregister doesn't work correctly / Get axis reference (necessary if joysticks gets disbled and enabled again)
                    if (powerJoystick.GetVerticalAxisName() != "" && CrossPlatformInputManager.AxisExists(powerJoystick.GetVerticalAxisName()))
                    {
                        verticalAxis = CrossPlatformInputManager.VirtualAxisReference(powerJoystick.GetVerticalAxisName());
                    }
                }
            }

            // Register d-pad axis
            if (powerType == PowerType.DPad)
            {
                if (powerDPad.useAxis == PowerDPad.UseAxis.Both || powerDPad.useAxis == PowerDPad.UseAxis.Horizontal)
                {
                    if (powerDPad.GetHorizontalAxisName() != "" && !CrossPlatformInputManager.AxisExists(powerDPad.GetHorizontalAxisName()))
                    {
                        horizontalAxis = new CrossPlatformInputManager.VirtualAxis(powerDPad.GetHorizontalAxisName());
                        CrossPlatformInputManager.RegisterVirtualAxis(horizontalAxis);
                    }
                    // Unregister doesn't work correctly / Get axis reference (necessary if d-pad gets disbled and enabled again)
                    if (powerDPad.GetHorizontalAxisName() != "" && CrossPlatformInputManager.AxisExists(powerDPad.GetHorizontalAxisName()))
                    {
                        horizontalAxis = CrossPlatformInputManager.VirtualAxisReference(powerDPad.GetHorizontalAxisName());
                    }
                }
                if (powerDPad.useAxis == PowerDPad.UseAxis.Both || powerDPad.useAxis == PowerDPad.UseAxis.Vertical)
                {
                    if (powerDPad.GetVerticalAxisName() != "" && !CrossPlatformInputManager.AxisExists(powerDPad.GetVerticalAxisName()))
                    {
                        verticalAxis = new CrossPlatformInputManager.VirtualAxis(powerDPad.GetVerticalAxisName());
                        CrossPlatformInputManager.RegisterVirtualAxis(verticalAxis);
                    }
                    // Unregister doesn't work correctly / Get axis reference (necessary if d-pad gets disbled and enabled again)
                    if (powerDPad.GetVerticalAxisName() != "" && CrossPlatformInputManager.AxisExists(powerDPad.GetVerticalAxisName()))
                    {
                        verticalAxis = CrossPlatformInputManager.VirtualAxisReference(powerDPad.GetVerticalAxisName());
                    }
                }
            }

            // Register button
            if (powerType == PowerType.Button)
            {
                if (powerButton.GetButtonName() != null)
                {
                    if (!CrossPlatformInputManager.ButtonExists(powerButton.GetButtonName()))
                    {
                        button = new CrossPlatformInputManager.VirtualButton(powerButton.GetButtonName());
                        CrossPlatformInputManager.RegisterVirtualButton(button);
                    }
                }
            }

            // Register button axis
            if (powerType == PowerType.Button)
            {
                if (powerButton.GetButtonToAxis() && powerButton.GetAxisName() != "")
                {
                    buttonAxisName = powerButton.GetAxisName();
                    if (!CrossPlatformInputManager.AxisExists(buttonAxisName))
                    {
                        buttonAxis = new CrossPlatformInputManager.VirtualAxis(buttonAxisName);
                        CrossPlatformInputManager.RegisterVirtualAxis(buttonAxis);
                    }
                    // Unregister doesn't work correctly / Get axis reference (necessary if button gets disbled and enabled again)
                    if (powerButton.GetAxisName() != "" && CrossPlatformInputManager.AxisExists(powerButton.GetAxisName()))
                    {
                        buttonAxis = CrossPlatformInputManager.VirtualAxisReference(powerButton.GetAxisName());
                    }
                }
            }
        }