public override void Update() { base.Update(); if (controller == null) { NRInput.LaserVisualActive = false; NRInput.ReticleVisualActive = false; var inputSystem = Service as IMixedRealityInputSystem; var handedness = NRInput.DomainHand == ControllerHandEnum.Left ? Handedness.Left : Handedness.Right; var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSource = inputSystem?.RequestNewGenericInputSource($"Nreal Light Controller", pointers, InputSourceType.Controller); controller = new NrealLightController(Microsoft.MixedReality.Toolkit.TrackingState.NotTracked, handedness, inputSource); controller.SetupConfiguration(typeof(NrealLightController)); for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem.RaiseSourceDetected(controller.InputSource, controller); } controller.UpdateController(); // Change RaycastMode if (NRInput.GetButtonUp(ControllerButton.HOME)) { var inputSystem = Service as IMixedRealityInputSystem; inputSystem.RaiseSourceLost(controller.InputSource, controller); controller = null; NRInput.RaycastMode = NRInput.RaycastMode == RaycastModeEnum.Laser ? RaycastModeEnum.Gaze : RaycastModeEnum.Laser; } }
void Update() { if ((!useMarker && !isRoomLoaded && NRInput.GetButtonUp(ControllerHandEnum.Left, ControllerButton.TRIGGER))) { RootID = 0; } if (RootID != -1 && !isRoomLoaded) { isRoomLoaded = true; if (OnLoadRoom != null) { OnLoadRoom(); } SceneManager.LoadSceneAsync("AWE_Room"); } //// Reset the world coordinates //if (ARInput.GetButtonDown(ControllerButtonEnum.OK) || ARInput.GetButtonDown(ControllerButtonEnum.HOME)) // specialNumber = 0; //// Double click OK, then click CANCEL for five times will reset marker //if (ARInput.GetButtonUp(ControllerButtonEnum.CANCEL)) //{ // specialNumber -= 1; // if (specialNumber == 1) // ResetMarker(); //} }
private void PrintInputState() { Debug.LogFormat("istouching:{0} getbutton app:{1} trigger:{2} home:{3} \n" + "getbuttondown app:{4} trigger:{5} home:{6} \n" + "getbuttonup app:{7} trigger:{8} home:{9} \n" + "origin touch:[{10}] gettouch:{11}", NRInput.IsTouching(), NRInput.GetButton(ControllerButton.APP), NRInput.GetButton(ControllerButton.TRIGGER), NRInput.GetButton(ControllerButton.HOME) , NRInput.GetButtonDown(ControllerButton.APP), NRInput.GetButtonDown(ControllerButton.TRIGGER), NRInput.GetButtonDown(ControllerButton.HOME) , NRInput.GetButtonUp(ControllerButton.APP), NRInput.GetButtonUp(ControllerButton.TRIGGER), NRInput.GetButtonUp(ControllerButton.HOME) , NRVirtualDisplayer.SystemButtonState.ToString(), NRInput.GetTouch(m_CurrentDebugHand).ToString("F3")); }
/// <summary> Updates this object. </summary> private void Update() { if (NRInput.GetAvailableControllersCount() < 2) { m_CurrentDebugHand = NRInput.DomainHand; } else { if (NRInput.GetButtonDown(ControllerHandEnum.Right, ControllerButton.TRIGGER)) { m_CurrentDebugHand = ControllerHandEnum.Right; } else if (NRInput.GetButtonDown(ControllerHandEnum.Left, ControllerButton.TRIGGER)) { m_CurrentDebugHand = ControllerHandEnum.Left; } } if (NRInput.GetButtonDown(m_CurrentDebugHand, ControllerButton.TRIGGER)) { AddExtraInfo("trigger_btn_down"); } if (NRInput.GetButtonDown(m_CurrentDebugHand, ControllerButton.HOME)) { AddExtraInfo("home_btn_down"); } if (NRInput.GetButtonDown(m_CurrentDebugHand, ControllerButton.APP)) { AddExtraInfo("app_btn_down"); } if (NRInput.GetButtonUp(m_CurrentDebugHand, ControllerButton.TRIGGER)) { AddExtraInfo("trigger_btn_up"); } if (NRInput.GetButtonUp(m_CurrentDebugHand, ControllerButton.HOME)) { AddExtraInfo("home_btn_up"); } if (NRInput.GetButtonUp(m_CurrentDebugHand, ControllerButton.APP)) { AddExtraInfo("app_btn_up"); } FollowMainCam(); RefreshInfoTexts(); }
public override void Update() { base.Update(); if (controller == null) { NRInput.LaserVisualActive = false; NRInput.ReticleVisualActive = false; var inputSystem = Service as IMixedRealityInputSystem; var handedness = NRInput.DomainHand == ControllerHandEnum.Left ? Handedness.Left : Handedness.Right; var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSource = inputSystem?.RequestNewGenericInputSource($"Nreal Light Controller", pointers, InputSourceType.Hand); controller = new NrealLightController(Microsoft.MixedReality.Toolkit.TrackingState.NotTracked, handedness, inputSource); controller.SetupConfiguration(typeof(NrealLightController)); for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem.RaiseSourceDetected(controller.InputSource, controller); } controller.UpdateController(); // Change RaycastMode if (NRInput.GetButtonUp(ControllerButton.APP)) { var inputSystem = Service as IMixedRealityInputSystem; inputSystem.RaiseSourceLost(controller.InputSource, controller); inputSystem.RaiseSourceDetected(controller.InputSource, controller); NRInput.RaycastMode = NRInput.RaycastMode == RaycastModeEnum.Laser ? RaycastModeEnum.Gaze : RaycastModeEnum.Laser; } // Set MixedRealityInputSystem if (homeMenu == null) { homeMenu = GameObject.FindObjectOfType <NRKernal.NRExamples.NRHomeMenu>(); var canvas = homeMenu?.GetComponentInChildren <Canvas>(); if (canvas != null) { if (canvas.gameObject.GetComponent <GraphicRaycaster>() == null) { canvas.gameObject.AddComponent <GraphicRaycaster>(); } if (canvas.gameObject.GetComponent <CanvasUtility>() == null) { canvas.gameObject.AddComponent <CanvasUtility>(); } } } }
/// <summary> Updates this object. </summary> private void Update() { if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_PreviousPos = NRInput.GetTouch(); } else if (NRInput.GetButton(ControllerButton.TRIGGER)) { UpdateScroll(); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { m_PreviousPos = Vector2.zero; } }
private void Update() { var deltaTouch = NRInput.GetDeltaTouch(); if (deltaTouch.y > float.Epsilon) { return; } var isSwipeRight = deltaTouch.x > float.Epsilon; var isSwipeLeft = deltaTouch.x < -float.Epsilon; switch (_state) { case State.Idle: if (isSwipeRight) { StartCoroutine(nameof(Play)); } break; case State.Play: if (isSwipeLeft) { StartCoroutine(nameof(Stop)); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { StartCoroutine(nameof(Pause)); } break; case State.Pause: if (isSwipeLeft) { StartCoroutine(nameof(Stop)); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { StartCoroutine(nameof(Play)); } break; default: throw new ArgumentOutOfRangeException(); } }
bool IInputController.IsUp(ButtonType type) { switch (type) { case ButtonType.One: return(NRInput.GetButtonUp(_inputSettings.One)); case ButtonType.Two: return(NRInput.GetButtonUp(_inputSettings.Two)); case ButtonType.Three: return(NRInput.GetButtonUp(_inputSettings.Three)); case ButtonType.Four: return(NRInput.GetButtonUp(_inputSettings.Four)); default: return(false); } }
private void JudgeDrop() { if (!IsMoveable) { return; } if (!IsBeingSelected) { return; } if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_TriggerDownTime = Time.time; m_TouchDownPos = NRInput.GetTouch(); } if (NRInput.GetButton(ControllerButton.TRIGGER) && !m_TouchMoved) { m_TouchMoved = Vector2.Distance(NRInput.GetTouch(), m_TouchDownPos) > JUDGE_TOUCH_MOVED_DISTANCE; } if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { if ((Time.time - m_TriggerDownTime) < SelectingRaycaster.clickInterval) { forceDeselectOnce = true; } if (NRInput.GetControllerType() == ControllerType.CONTROLLER_TYPE_PHONE && m_TouchMoved) { forceDeselectOnce = false; } m_TouchMoved = false; } else if (NRInput.GetButtonUp(ControllerButton.HOME)) { forceDeselectOnce = true; } if (forceDeselectOnce) { forceDeselectOnce = false; Deselected(); } }
private void Update() { if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { NRInput.TriggerHapticVibration(0.5f); AddExtraInfo("trigger_btn_down"); } if (NRInput.GetButtonDown(ControllerButton.HOME)) { AddExtraInfo("home_btn_down"); } if (NRInput.GetButtonDown(ControllerButton.APP)) { AddExtraInfo("app_btn_down"); } if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { AddExtraInfo("trigger_btn_up"); } if (NRInput.GetButtonUp(ControllerButton.HOME)) { AddExtraInfo("home_btn_up"); } if (NRInput.GetButtonUp(ControllerButton.APP)) { AddExtraInfo("app_btn_up"); } FollowMainCam(); RefreshInfoTexts(); }
bool IInputController.IsTriggerUp(ControllerType type) => NRInput.GetButtonUp(ControllerButton.TRIGGER);
// Update is called once per frame void Update() { // コントローラ(左手右手)情報の取得 // 複数のコントローラを使用している場合、使用したコントローラを判断するための処理。 // 今後のハンドジェスチャーを見越しての処理か? if (NRInput.GetAvailableControllersCount() < 2) { m_CurrentDebugHand = NRInput.DomainHand; } else { if (NRInput.GetButtonDown(ControllerHandEnum.Right, ControllerButton.TRIGGER)) { m_CurrentDebugHand = ControllerHandEnum.Right; } else if (NRInput.GetButtonDown(ControllerHandEnum.Left, ControllerButton.TRIGGER)) { m_CurrentDebugHand = ControllerHandEnum.Left; } } // Trigger以外のボタン動作をハンドリングするにはIPointerDownHandlerではなく、Updateでハンドリングする // Triggerだけで良ければIPointerDownHandler/IPointerUpHandlerで実装するほうが良い if (NRInput.GetButtonDown(this.m_CurrentDebugHand, ControllerButton.APP)) { this.director.WriteLog("OnPointerDown_APP"); this.currentDownButton = ControllerButton.APP; if (this.unityChanEnterState) { GetComponent <Animator>().SetTrigger("doJump"); } } else if (NRInput.GetButtonDown(this.m_CurrentDebugHand, ControllerButton.TRIGGER)) { this.director.WriteLog("OnPointerDown_TRIGGER"); this.currentDownButton = ControllerButton.TRIGGER; } else if (NRInput.GetButtonDown(this.m_CurrentDebugHand, ControllerButton.GRIP)) { this.director.WriteLog("OnPointerDown_GRID"); this.currentDownButton = ControllerButton.GRIP; } else if (NRInput.GetButtonDown(this.m_CurrentDebugHand, ControllerButton.HOME)) { this.director.WriteLog("OnPointerDown_HOME"); this.currentDownButton = ControllerButton.HOME; } else if (NRInput.GetButtonDown(this.m_CurrentDebugHand, ControllerButton.TOUCHPAD_BUTTON)) { this.director.WriteLog("OnPointerDown_TOUCHPAD_BUTTON"); this.currentDownButton = ControllerButton.TOUCHPAD_BUTTON; } if (NRInput.GetButtonUp(this.m_CurrentDebugHand, ControllerButton.APP) || NRInput.GetButtonUp(this.m_CurrentDebugHand, ControllerButton.TRIGGER) || NRInput.GetButtonUp(this.m_CurrentDebugHand, ControllerButton.GRIP) || NRInput.GetButtonUp(this.m_CurrentDebugHand, ControllerButton.HOME) || NRInput.GetButtonUp(this.m_CurrentDebugHand, ControllerButton.TOUCHPAD_BUTTON)) { this.director.WriteLog("OnPointerUp_all"); this.currentDownButton = 0; } }
private void Update() { brain1 = GameObject.Find("Brain"); solar = GameObject.Find("Rotate"); var rotate = solar.GetComponent <Button>(); var button = brain1.GetComponent <Button>(); // var button2 = button.onClick.AddListener(() => { if (brn == false) { brn = true; brnenum = brnlist.Brain2; brainText.text = "Brain 2"; } else { brn = false; brnenum = brnlist.Brain1; brainText.text = "Brain 1"; } }); rotate.onClick.AddListener(() => { if (controlZoom == false) { controlZoom = true; buttonText.text = "Zoom"; } else { controlZoom = false; buttonText.text = "Rotate"; } }); switch (brnenum) { case brnlist.Brain1: brain1.SetActive(true); brain2.SetActive(false); break; case brnlist.Brain2: brain1.SetActive(false); brain2.SetActive(true); break; } if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_PreviousPos = NRInput.GetTouch(); } else if (NRInput.GetButton(ControllerButton.TRIGGER)) { UpdateScroll(); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { m_PreviousPos = Vector2.zero; } }