protected virtual void Update() { touches = Input.touches; for (int i = 0; i < touches.Length; i++) { if (touches[i].phase == TouchPhase.Began) { InputObserver.OnInputDown(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Moved) { InputObserver.OnInput(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Stationary) { InputObserver.OnInput(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Ended) { InputObserver.OnInputUp(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Canceled) { InputObserver.OnInputUp(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } } }
protected virtual void Update() { for (int i = 0; i < keyCodes.Length; i++) { if (Input.GetKeyDown(keyCodes[i])) { InputObserver.OnInputDown(new KeyInputArgs(keyCodes[i])); } if (Input.GetKey(keyCodes[i])) { InputObserver.OnInput(new KeyInputArgs(keyCodes[i])); } if (Input.GetKeyUp(keyCodes[i])) { InputObserver.OnInputUp(new KeyInputArgs(keyCodes[i])); } } }
protected virtual void Update() { if (Input.GetMouseButtonDown(0)) { InputObserver.OnInputDown(new MouseInputArgs(Input.mousePosition)); mouseButtonPosition = Input.mousePosition; } if (Input.GetMouseButton(0)) { Vector2 delta = (Vector2)Input.mousePosition - mouseButtonPosition; InputObserver.OnInput(new MouseInputArgs(Input.mousePosition, delta)); mouseButtonPosition = Input.mousePosition; } if (Input.GetMouseButtonUp(0)) { Vector2 delta = (Vector2)Input.mousePosition - mouseButtonPosition; InputObserver.OnInputUp(new MouseInputArgs(Input.mousePosition, delta)); } }