//单击返回键 public void ClickBack() { //左手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloLeftButtonUp(NoloButtonID.Back)) { LeftBackClick?.Invoke(NoloDeviceType.LeftController); } //右手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloRightButtonUp(NoloButtonID.Back)) { LeftBackClick?.Invoke(NoloDeviceType.RightController); } }
//双击触摸板 public void DoubleClickTouchPad() { if (NoloVRInput.singleton.OnNoloLeftButtonUp(NoloButtonID.TouchPad)) //system = menu { //Debug.Log("双击触摸板"); if (Time.time - touchPad_PreTime_L <= spacingTime) { LeftTouchPadDoubleClick?.Invoke(NoloDeviceType.LeftController); touchPad_PreTime_L = 0; } else { touchPad_PreTime_L = Time.time; } } if (NoloVRInput.singleton.OnNoloRightButtonUp(NoloButtonID.TouchPad)) { if (Time.time - touchPad_PreTime_R <= spacingTime) { RightTouchPadDoubleClick?.Invoke(NoloDeviceType.RightController); touchPad_PreTime_R = 0; } else { touchPad_PreTime_R = Time.time; } } }
//单击触摸板 public void ClickTouchPad() { //左手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloLeftButtonUp(NoloButtonID.TouchPad)) { LeftTouchPadClick?.Invoke(NoloDeviceType.LeftController); } //右手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloRightButtonUp(NoloButtonID.TouchPad)) { RightTouchPadClick?.Invoke(NoloDeviceType.RightController); } }
//单击系统键 public void ClickSystem() { //左手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloLeftButtonUp(NoloButtonID.System)) { LeftSystemClick?.Invoke(NoloDeviceType.LeftController); } //右手柄触摸板抬起 if (NoloVRInput.singleton.OnNoloRightButtonUp(NoloButtonID.System)) { RightSystemClick?.Invoke(NoloDeviceType.RightController); } }
/// <summary> /// Updates status of gui control /// </summary> /// <param name="ihn">Ihn that triggered the update</param> public virtual void Update(Ihn ihn) { for (int i = 0; i < Children.Count; i++) { if (Children[i].Enabled) { Children[i].Update(ihn); } } if (Enabled) { var shouldInvokeMouseEvents = true; for (int i = 0; i < Children.Count; i++) { if (Children[i].Enabled) { if (new Rectangle(MouseHelper.X, MouseHelper.Y, 1, 1).Intersects(new FloatRect(Children[i].Root.X, Children[i].Root.Y, Children[i].Size.X, Children[i].Size.Y).ToRect())) { shouldInvokeMouseEvents = false; if (_mouseOver) { _mouseOver = false; if (MouseExit != null) { MouseExit.Invoke(this); } } break; } } } if (shouldInvokeMouseEvents) { InvokeMouseEvents(); } } }
private void InvokeMouseEvents() { if (new Rectangle(MouseHelper.X, MouseHelper.Y, 1, 1).Intersects(new FloatRect(Root.X, Root.Y, Size.X, Size.Y).ToRect())) { if (MouseOver != null) { MouseOver.Invoke(this); } if (!_mouseOver) { if (MouseEnter != null) { MouseEnter.Invoke(this); } } _mouseOver = true; if (MouseHelper.MouseLeftDown()) { if (MouseDown != null) { MouseDown.Invoke(this); } } if (MouseHelper.MouseLeftPressed()) { if (MousePressed != null) { MousePressed.Invoke(this); } } if (MouseHelper.MouseLeftReleased()) { if (MouseReleased != null) { MouseReleased.Invoke(this); } } } else if (_mouseOver) { _mouseOver = false; if (MouseExit != null) { MouseExit.Invoke(this); } } }