public void Tick() { if (Input.GetMouseButtonDown(MouseButtonIndex)) { ButtonDown?.Invoke(ScreenToWorld(Input.mousePosition)); } if (Input.GetMouseButton(MouseButtonIndex)) { ButtonHold?.Invoke(ScreenToWorld(Input.mousePosition)); } if (Input.GetMouseButtonUp(MouseButtonIndex)) { ButtonUp?.Invoke(ScreenToWorld(Input.mousePosition)); } }
public void Initialize() { buttons.Add(new MouseButton( () => mouseCore.LeftButton, () => ButtonPress?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Left)), () => ButtonHold?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Left)), () => ButtonLift?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Left)))); buttons.Add(new MouseButton( () => mouseCore.MiddleButton, () => ButtonPress?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Middle)), () => ButtonHold?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Middle)), () => ButtonLift?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Middle)))); buttons.Add(new MouseButton( () => mouseCore.RightButton, () => ButtonPress?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Right)), () => ButtonHold?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Right)), () => ButtonLift?.Invoke(this, new MouseButtonInteraction(X, Y, Input.MouseButton.Right)))); }
public void Tick() { var touch = Input.GetTouch(TouchIndex); if (touch.phase == TouchPhase.Began) { ButtonDown?.Invoke(ScreenToWorld(touch.position)); } if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) { ButtonHold?.Invoke(ScreenToWorld(touch.position)); } if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { ButtonUp?.Invoke(ScreenToWorld(Input.mousePosition)); } }
protected override void OnHold(InputState istate, float holdTime) { ButtonHold?.Invoke(this, new HUDButtonEventArgs(HUDButtonEventType.Hold)); }