/// <summary> /// Returns true during the frame the user action event the touch button identified by buttonName. /// </summary> /// <param name="buttonName"></param> /// <param name="m_Event"></param> /// <returns></returns> public static bool GetAction(string buttonName, EActionEvent m_Event) { if (!m_Active) { return(false); } for (int i = 0; i < buttons.Length; i++) { if (buttons[i].identifier == buttonName) { switch (m_Event) { case EActionEvent.Down: return(buttons[i].isDOWN); case EActionEvent.Press: return(buttons[i].isPRESSED); case EActionEvent.Up: return(buttons[i].isUP); case EActionEvent.Click: return(buttons[i].isCLICK); default: break; } } } Debug.LogError("Button: " + buttonName + " not found!"); return(false); }
/// <summary> /// Bind your void to button action, identified by buttonName. Called established event in EActionEvent. /// </summary> /// <param name="buttonName"></param> /// <param name="m_Handler"></param> /// <param name="EActionEvent"></param> public static void BindAction(string buttonName, EActionEvent m_Event, ActionEventHandler m_Handler) { foreach (TCKButton button in buttons) { if (button.MyName == buttonName) { button.BindAction(m_Handler, m_Event); return; } } Debug.LogError("Button: " + buttonName + " Not Found."); }
/// <summary> /// Returns true during the frame the user action event the touch button identified by buttonName. /// </summary> /// <param name="buttonName"></param> /// <param name="m_Event"></param> /// <returns></returns> public static bool GetAction(string buttonName, EActionEvent m_Event) { if (!active) { return(false); } switch (m_Event) { case EActionEvent.Down: foreach (TCKButton button in buttons) { if (button.MyName == buttonName) { return(button.isDOWN); } } break; case EActionEvent.Press: foreach (TCKButton button in buttons) { if (button.MyName == buttonName) { return(button.isPRESSED); } } break; case EActionEvent.Up: foreach (TCKButton button in buttons) { if (button.MyName == buttonName) { return(button.isUP); } } break; case EActionEvent.Click: foreach (TCKButton button in buttons) { if (button.MyName == buttonName) { return(button.isCLICK); } } break; } Debug.LogError("Button: " + buttonName + " not found!"); return(false); }
/// <summary> /// Unbind your void of controller axis action, identified by controllerName & EActionEvent. /// </summary> /// <param name="controllerName"></param> /// <param name="m_Handler"></param> /// <param name="EActionEvent"></param> public static void UnbindAxes(string controllerName, EActionEvent m_Event, AxesEventHandler m_Handler) { foreach (AxesBasedController controller in abControllers) { if (controller.MyName == controllerName) { controller.UnBindAxes(m_Handler, m_Event); return; } } Debug.LogError("Controller: " + controllerName + " not found!"); }
// // Bind Action internal static void BindAction(string m_Name, EActionEvent m_Event, ActionHandler m_Handler) { foreach (ActionData aData in ActionDB) { if (aData.name == m_Name) { switch (m_Event) { case EActionEvent.Down: aData.actionEvents.useDown = true; if (aData.actionEvents.downHandler != m_Handler) { aData.actionEvents.downHandler += m_Handler; } break; case EActionEvent.Press: aData.actionEvents.usePress = true; if (aData.actionEvents.pressHandler != m_Handler) { aData.actionEvents.pressHandler += m_Handler; } break; case EActionEvent.Up: aData.actionEvents.useUp = true; if (aData.actionEvents.upHandler != m_Handler) { aData.actionEvents.upHandler += m_Handler; } break; } return; } } Debug.LogError("Action " + m_Name + " Not Found."); }
// Bind Action internal void BindAxes(AxesEventHandler m_Handler, EActionEvent EActionEvent) { switch (EActionEvent) { case EActionEvent.Down: useDown = true; if (downHandler != m_Handler) { downHandler += m_Handler; } break; case EActionEvent.Press: usePress = true; if (pressHandler != m_Handler) { pressHandler += m_Handler; } break; case EActionEvent.Up: useUp = true; if (upHandler != m_Handler) { upHandler += m_Handler; } break; case EActionEvent.Click: useClick = true; if (clickHandler != m_Handler) { clickHandler += m_Handler; } break; } }
// UnBind Action internal void UnBindAxes(AxesEventHandler m_Handler, EActionEvent EActionEvent) { switch (EActionEvent) { case EActionEvent.Down: if (downHandler == m_Handler) { downHandler -= m_Handler; useDown = (downHandler != null); } break; case EActionEvent.Press: if (pressHandler == m_Handler) { pressHandler -= m_Handler; usePress = (pressHandler != null); } break; case EActionEvent.Up: if (upHandler == m_Handler) { upHandler -= m_Handler; useUp = (upHandler != null); } break; case EActionEvent.Click: if (clickHandler == m_Handler) { clickHandler -= m_Handler; useClick = (clickHandler != null); } break; } }
// Get Action internal static bool GetAction(string m_Name, EActionEvent m_Event) { foreach (ActionData aData in ActionDB) { if (aData.name == m_Name) { switch (m_Event) { case EActionEvent.Down: if (aData.type == EActionType.KeyCode || aData.type == EActionType.Mixed) { foreach (KeyCode key in aData.keys) { if (Input.GetKeyDown(key)) { return(true); } } } if (aData.type == EActionType.Axis || aData.type == EActionType.Mixed) { foreach (ActionData.ActionAxis aAxis in aData.actionAxes) { EAxisState axisState = aAxis.getAxisState; if (axisState == EAxisState.NegativeDown || axisState == EAxisState.PositiveDown) { return(true); } } } break; case EActionEvent.Press: if (aData.type == EActionType.KeyCode || aData.type == EActionType.Mixed) { foreach (KeyCode key in aData.keys) { if (Input.GetKey(key)) { return(true); } } } if (aData.type == EActionType.Axis || aData.type == EActionType.Mixed) { foreach (ActionData.ActionAxis aAxis in aData.actionAxes) { EAxisState axisState = aAxis.getAxisState; if (axisState == EAxisState.NegativePress || axisState == EAxisState.PositivePress) { return(true); } } } break; case EActionEvent.Up: if (aData.type == EActionType.KeyCode || aData.type == EActionType.Mixed) { foreach (KeyCode key in aData.keys) { if (Input.GetKeyUp(key)) { return(true); } } } if (aData.type == EActionType.Axis || aData.type == EActionType.Mixed) { foreach (ActionData.ActionAxis aAxis in aData.actionAxes) { EAxisState axisState = aAxis.getAxisState; if (axisState == EAxisState.NegativeUp || axisState == EAxisState.PositiveUp) { return(true); } } } break; } return(false); } } Debug.LogError("Action " + m_Name + " Not Found!"); return(false); }
// Get Action public static bool GetAction(string m_Name, EActionEvent m_Event) { return(InputSettings.GetAction(m_Name, m_Event)); }
// Unbind Action public static void UnbindAction(string m_Name, EActionEvent m_Event, ActionHandler m_Handler) { InputSettings.UnbindAction(m_Name, m_Event, m_Handler); }