public static bool GetButtonUp(string button, INPUT_CONTEXT context) { if (contextStack.Peek() == context) { return Input.GetButtonUp(button); } return false; }
public static bool GetKey(KeyCode key, INPUT_CONTEXT context) { if (contextStack.Peek() == context) { return Input.GetKey(key); } return false; }
public static float GetAxisRaw(string axis, INPUT_CONTEXT context) { if (contextStack.Peek() == context) { return Input.GetAxisRaw(axis); } return 0; }
/// <summary> /// Pushes an input context onto the stack. We don't push if it already exists. /// </summary> /// <param name="context"></param> public static void PushInputContext(INPUT_CONTEXT context) { if (context == contextStack.Peek()) { Debug.Log("[InputManager.cs] Context is already " + contextStack.Peek().ToString()); return; } contextStack.Push(context); Debug.Log("[InputManager.cs] Added context " + contextStack.Peek().ToString()); }
/// <summary> /// Pops an input context off of the stack. If it's not on the top, we don't pop. /// </summary> /// <param name="context"></param> public static void PopInputContext(INPUT_CONTEXT context) { if (contextStack.Count == 0) { contextStack.Push(INPUT_CONTEXT.NONE); return; } if (contextStack.Peek() == context) { INPUT_CONTEXT removedContext = contextStack.Pop(); Debug.Log("InputManger: Removed context " + removedContext.ToString()); } }
/// <summary> /// Determines whether the provided context is on the current /// input context stack. /// </summary> /// <param name="context"></param> /// <returns></returns> public static bool HasContext(INPUT_CONTEXT context) { return contextStack.Contains(context); }
public static bool GetMouseButtonDown(int button, INPUT_CONTEXT context) { if (contextStack.Peek() == context) { return Input.GetMouseButtonDown(button); } return false; }