Ejemplo n.º 1
0
 void OnPowerButtonUp(GameObject sender)
 {
     if (sender == powerButton.gameObject && CrossPlatformInputManager.ButtonExists(powerButton.GetButtonName()))
     {
                         #if MOBILE_INPUT
         CrossPlatformInputManager.SetButtonUp(powerButton.GetButtonName());
                         #endif
     }
 }
 void Start()
 {
     if (CrossPlatformInputManager.ButtonExists(Name))
     {
         CrossPlatformInputManager.UnRegisterVirtualButton(Name);
     }
     myBt = new CrossPlatformInputManager.VirtualButton(Name);
     CrossPlatformInputManager.RegisterVirtualButton(myBt);
 }
        void DoGetButtonExists()
        {
            bool _exists;

                        #if CROSS_PLATFORM_INPUT
            _exists = CrossPlatformInputManager.ButtonExists(buttonName.Value);
                        #endif

            buttonExists.Value = _exists;
            Fsm.Event(_exists?buttonExistsEvent:buttonDoNotExistsEvent);
        }
Ejemplo n.º 4
0
 void CreateVirtualButton()
 {
     if (m_ButtonName != "")
     {
         if (CrossPlatformInputManager.ButtonExists(m_ButtonName))
         {
             CrossPlatformInputManager.UnRegisterVirtualButton(m_ButtonName);
         }
         m_VirtualButton = new CrossPlatformInputManager.VirtualButton(m_ButtonName);
         CrossPlatformInputManager.RegisterVirtualButton(m_VirtualButton);
     }
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
0
        void OnDisable()
        {
            // Unsubscribe 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;
            }
            // Unsubscribe normal button events
            if (powerType == PowerType.Button)
            {
                PowerButton.OnPowerButtonDown -= OnPowerButtonDown;
                PowerButton.OnPowerButtonUp   -= OnPowerButtonUp;
            }

            // Unregister axis and button
            if (horizontalAxis != null && CrossPlatformInputManager.AxisExists(horizontalAxis.name))
            {
                CrossPlatformInputManager.UnRegisterVirtualAxis(horizontalAxis.name);
            }
            if (verticalAxis != null && CrossPlatformInputManager.AxisExists(verticalAxis.name))
            {
                CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxis.name);
            }
            if (buttonAxis != null && CrossPlatformInputManager.AxisExists(buttonAxisName))
            {
                CrossPlatformInputManager.UnRegisterVirtualAxis(buttonAxisName);
            }
            if (button != null && CrossPlatformInputManager.ButtonExists(button.name))
            {
                CrossPlatformInputManager.UnRegisterVirtualButton(button.name);
            }
        }
Ejemplo n.º 7
0
    private void Awake()
    {
        if (!CrossPlatformInputManager.ButtonExists(Name))
        {
            vbutton = new CrossPlatformInputManager.VirtualButton(Name);
            CrossPlatformInputManager.RegisterVirtualButton(vbutton);
            print("registered");
        }
        if (CrossPlatformInputManager.ButtonExists(Name))
        {
            print("verfied registration");
        }

        //  gameObject.SetActive(false);
    }
Ejemplo n.º 8
0
        public override void OnEnter()
        {
                        #if CROSS_PLATFORM_INPUT
            if (!CrossPlatformInputManager.ButtonExists(buttonName.Value))
            {
                Fsm.Event(buttonNotFound);
                Finish();
                return;
            }
                        #endif

            DoSetButton();

            if (!everyFrame)
            {
                Finish();
            }
        }
Ejemplo n.º 9
0
        void NegVTriggerButtonUp(GameObject sender)
        {
            if (powerType == PowerType.Joystick)
            {
                if (sender == powerJoystick.gameObject && CrossPlatformInputManager.ButtonExists(powerJoystick.GetVNegButtonName()))
                {
                                        #if MOBILE_INPUT
                    CrossPlatformInputManager.SetButtonUp(powerJoystick.GetVNegButtonName());
                                        #endif
                }
            }

            if (powerType == PowerType.DPad)
            {
                if (sender == powerDPad.gameObject && CrossPlatformInputManager.ButtonExists(powerDPad.GetVNegButtonName()))
                {
                                        #if MOBILE_INPUT
                    CrossPlatformInputManager.SetButtonUp(powerDPad.GetVNegButtonName());
                                        #endif
                }
            }
        }
Ejemplo n.º 10
0
        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());
                    }
                }
            }
        }