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); }
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); } }
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 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); } }
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); }
public override void OnEnter() { #if CROSS_PLATFORM_INPUT if (!CrossPlatformInputManager.ButtonExists(buttonName.Value)) { Fsm.Event(buttonNotFound); Finish(); return; } #endif DoSetButton(); if (!everyFrame) { Finish(); } }
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 } } }
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()); } } } }