private void AxesStateLabel(VRButton button) { var axes = VRInput.GetAxes(button); UnityGUI.Label(button.ToString() + " X: " + axes[0].ToString("0.000")); UnityGUI.Label(button.ToString() + " Y: " + axes[1].ToString("0.000")); }
//コントローラ管理/////////////////////////////////////////////////////////// //コントローラのボタンを押すと呼ばれる(数字がボタンの種類) public void ControllerPulse(VRButton kind, bool right) { switch (kind) { case VRButton.TriggerTouchDown: break; case VRButton.TriggerPressDown: if (RuneList.Count > 0) { CheckRuneList(); //ここでルーンが完成しているかを判定 } break; case VRButton.TriggerUp: break; case VRButton.GripDown: if (RuneList.Count > 0) { CheckRuneList(); //ここでルーンが完成しているかを判定 } break; case VRButton.GripUp: break; } }
void FixedUpdate() { if (Physics.Raycast(transform.position, transform.forward, out hit, rayDistance, layer)) { //Debug.Log("hit"); //Debug.Log($"distance:{hit.distance}"); //Debug.Log($"hit point:{hit.point}"); //Debug.Log($"normal: {hit.normal}"); reticle.localScale = startSize * error * hit.distance; reticle.position = hit.point + new Vector3(0, 0, -0.01f); reticle.localRotation = Quaternion.LookRotation(hit.normal); vrButton = hit.collider.GetComponent <VRButton>(); if (vrButton && Input.GetMouseButtonDown(0)) { vrButton.Click(); } } else { reticle.localPosition = Vector3.zero; reticle.localRotation = Quaternion.identity; reticle.localScale = startSize; } }
/// <summary> /// Update Function, process through Switch Button current Inputs. /// </summary> void Update() { // On Button Press if (Input.GetButtonDown(VRButton.toString(SwitchButton))) { setActivaton(true); } // If Button is Pressed if (Input.GetButton(VRButton.toString(SwitchButton))) { timeSincePress += Time.deltaTime; if (timeSincePress > TimeForChange) { timeSincePress -= TimeForChange; hasBeenChanged = true; NextButton(); } } // On Button Release if (Input.GetButtonUp(VRButton.toString(SwitchButton))) { if (!hasBeenChanged) { setActivaton(false); } timeSincePress = 0; hasBeenChanged = false; } }
/// <summary> /// Update Function, process input by cycling through items or changing the activation state of the Canvas. /// </summary> void Update() { // Turn Inventory On & Off if (VRButton.onPressed(SwitchButton)) { generatorInstance.gameObject.SetActive(CurrentInventoryState = !CurrentInventoryState); if (CurrentInventoryState) { SaveHandIndexes(); } else { ComputeSelection(MGR_VRControls.get.RightHand, MGR_VRControls.get.LeftHand); } } // Cycle Through Items if (CurrentInventoryState) { if (VRButton.onPressed(CycleLeftHand)) { CycleItem(VRHand.Hand.LEFT); } if (VRButton.onPressed(CycleRightHand)) { CycleItem(VRHand.Hand.RIGHT); } } }
public static bool GetUp(VRButton input) { VRAxis axisInput = (VRAxis)input; if (axisInput.ToString() == input.ToString()) { //input is also an axis if (GetAxisRaw(axisInput) <= 0) { //input not recieved if (axisWasBeingHeld[axisInput]) { //input is new (wasn't previously being held axisWasBeingHeld[axisInput] = false; return(true); } } } else { return(Input.GetButtonUp(input.ToString())); } return(false); }
public static bool GetDown(VRButton input) { //if cast results in different value then inputs are mutually exclusive VRAxis axisInput = (VRAxis)input; if (axisInput.ToString() == input.ToString()) //input is also an axis { if (GetAxisRaw(axisInput) > 0) { //input recieved if (axisAvailable[axisInput]) { //input is new (wasn't previously being held axisAvailable[axisInput] = false; return(true); } } } else //input is a button { return(Input.GetButtonDown(input.ToString())); } return(false); }
void Update() { float step = (second > 0) ? Time.deltaTime / second : 1f; RaycastHit hit; if (Physics.Raycast(observer.transform.position, observer.transform.forward, out hit, Mathf.Infinity, layerMask)) { VRButton b = hit.collider.gameObject.GetComponent <VRButton>(); if (b != null) { Vector3 tmp = ready.transform.localScale; tmp.x += step; ready.transform.localScale = tmp; if (tmp.x >= 1) { tmp.x = 0; ready.transform.localScale = tmp; if (OnPress != null) { OnPress(); } } } } }
protected override void OnEnable() { base.OnEnable(); _button = (VRButton)target; _setColliderAuto = serializedObject.FindProperty("SetColliderAuto"); _clickableWithRaycast = serializedObject.FindProperty("LaserClickable"); _clickableUsingControllers = serializedObject.FindProperty("ControllerClickable"); }
public override void InitFind() { base.InitFind(); button = FindTool.FindChildComponent <VRButton>(transform, "buttonGroup"); WaiQuan = FindTool.FindChildNode(transform, "buttonGroup/nishizhen"); NeiQuan = FindTool.FindChildNode(transform, "buttonGroup/shunshizhen"); Center = FindTool.FindChildNode(transform, "buttonGroup/nishizhen1"); image = FindTool.FindChildComponent <Image>(transform, "buttonGroup/yuan"); }
/// <summary> /// Update Function, change the Camera to the next on the list. /// </summary> private void Update() { if (VRButton.onPressed(switchButton) && AllCams != null) { if (MGR_Camera.ChangeCamera(AllCams[(currIndex + 1) % AllCams.Count])) { currIndex = ++currIndex % AllCams.Count; } } }
/// <summary> /// Some interactions happen every frame when the controller is /// in a collider /// </summary> /// <param name="p_collider">P collider.</param> void OnTriggerStay(Collider p_collider) { if (TriggerPressed && !TriggerReset) { VRButton button = p_collider.GetComponent <VRButton> ( ); if (button) { button.ButtonPressed( ); } } }
private void Click(VRButton btn) { clickedFrame = Time.frameCount; if (clickSound) { if (UISounds.Instance != null) { UISounds.Instance.PlayClick(); } } OnButtonDown(btn); }
///we need to make sure this is called after the VRInput updates... protected virtual void DoUpdate() { lastUpdateFrame = Time.frameCount; if (input != null) { if (input.Target == this) { if (isTarget) { ContinueGaze(); } else { if (input.TargetCollider == entryTarget) { BeginGaze(); } } VRButton btn = input.PrimaryButton; VRButton.VRButtonState buttonState = btn.State; switch (buttonState) { case VRButton.VRButtonState.Down: Click(btn); break; case VRButton.VRButtonState.Up: OnButtonUp(btn); break; case VRButton.VRButtonState.Held: OnButtonHeld(btn); break; default: case VRButton.VRButtonState.None: break; } } else { if (isTarget) { EndGaze(); } ///otherwise, we aren't the target and never were. } } }
void OnEnable() { Button = GetComponent <VRButton> (); if (Button == null) { Debug.LogError("VRButton is null"); } Collider collider = GetComponent <Collider> (); collider.isTrigger = true; // This button should only work as a trigger }
public static bool GetUp(VRButton input) { if (GetAxisRaw(input) <= 0) //input not recieved { if (axisWasBeingHeld[input]) //input is new (wasn't previously being held { axisWasBeingHeld[input] = false; return(true); } } return(false); }
private void InitVRButton(VRButton vRButton, int number) { vRButton.LeftSteamVrLaserPointer = SphereControl.Instance.LeftsteamVR_LaserPointer; vRButton.RightSteamVrLaserPointer = SphereControl.Instance.RightsteamVR_LaserPointer; vRButton.mOnEnter.AddListener(() => { Menu_Button_OnEnter(vRButton.transform, number); }); vRButton.mOnUp.AddListener(() => { Menu_Button_OnUp(vRButton.transform, number); }); }
public static bool GetDown(VRButton input) { if (GetAxisRaw(input) > 0) //input recieved { if (axisAvailable[input]) //input is new (wasn't previously being held { axisAvailable[input] = false; return(true); } } return(false); }
private void TriggerStay(Collider other, VRSensor sensor) { ControllerInformation controller = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>()); ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation)); if (grabObjInfo.buttonInRange == null) { VRButton button = other.GetComponent <VRButton>(); if (button != null) { grabObjInfo.buttonInRange = button; button.OnControllerEnter(); } } }
private void TriggerExit(Collider other, VRSensor sensor) { ControllerInformation controller = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>()); ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation)); VRButton button = other.GetComponent <VRButton>(); //we check if it was a button and if it was the one in range if (button != null && button == grabObjInfo.buttonInRange) { grabObjInfo.buttonInRange = null; //we get rid of the color again button.OnControllerLeave(); } }
private void TriggerEnter(Collider other, VRSensor sensor) { ControllerInformation controller = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>()); ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation)); VRButton button = other.GetComponent <VRButton>(); //we check if it is a button and we are not already interacting with one if (button != null && grabObjInfo.buttonInRange == null) { grabObjInfo.buttonInRange = button; //And then we apply color to the button.. button.OnControllerEnter(); } }
/// <summary> /// Handle when the controller leaves the collider /// </summary> /// <param name="p_collider">P collider.</param> void OnTriggerExit(Collider p_collider) { VRHoverable hover = p_collider.GetComponent <VRHoverable> ( ); if (hover) { hover.HoverEnded( ); } VRButton button = p_collider.GetComponent <VRButton> ( ); if (button) { button.ButtonHoverEnd( ); } }
private void ButtonStateLabel(VRButton button) { var state = "Up"; if (VRInput.GetButton(button)) { state = "Down"; } else if (VRInput.GetTouch(button)) { state = "Touching"; } else if (VRInput.GetHovering(button) > Mathf.Epsilon) { state = "Hovering"; } UnityGUI.Label(button.ToString() + ": " + state); }
public override void InitFind() { base.InitFind(); BGCanvasGroup = FindTool.FindChildComponent <CanvasGroup>(transform, "bg"); TextGroup = FindTool.FindChildComponent <CanvasGroup>(transform, "TextGroup"); Teach1 = FindTool.FindChildComponent <CanvasGroup>(transform, "1"); Teach2 = FindTool.FindChildComponent <CanvasGroup>(transform, "2"); Teach3 = FindTool.FindChildComponent <CanvasGroup>(transform, "3"); ContentText = FindTool.FindChildComponent <Text>(transform, "TextGroup/Text"); baize = FindTool.FindChildComponent <Image>(transform, "baize"); jiantou = FindTool.FindChildComponent <Animation>(transform, "1/jiantou"); shoubing_left = FindTool.FindChildComponent <Animation>(transform, "2/shoubingGroup/left"); shoubing_right = FindTool.FindChildComponent <Animation>(transform, "2/shoubingGroup/right"); Frame = FindTool.FindChildComponent <Animator>(transform, "1/frame"); CloseButton = FindTool.FindChildComponent <VRButton>(transform, "3/Text"); }
protected override void OnButtonUp(VRButton button) { }
protected override void OnButtonHeld(VRButton button) { }
protected override void OnButtonDown(VRButton button) { }
public static bool GetUp(GenericVRButton input, Handedness handedness) { VRButton vrButton = (VRButton)Enum.Parse(typeof(VRButton), handedness.ToString() + input.ToString()); return(GetUp(vrButton)); }
//コントローラ管理/////////////////////////////////////////////////////////// //コントローラのボタンを押すと呼ばれる(数字がボタンの種類) public void ControllerPulse(VRButton kind, bool right) { switch (kind) { case VRButton.TriggerTouchDown: break; case VRButton.TriggerPressDown: if (Pz.GetF_Magic()) //魔法が打てる状態かどうかを確認 { if (right) //右トリガーで魔法発動 { /* * if(stockMagic[0] == 1)//セイバー * { * SelectMagic[stockMagic[0]].SendMessage("Fire"); * break; * } * if(stockMagic[0] == 4)//ボム * { * SelectMagic[stockMagic[0]].SendMessage("Fire"); * break; * } * if (stockMagic[0] == 6)//ブーメラン * { * SelectMagic[stockMagic[0]].SendMessage("Fire"); * break; * } */ if (stockMagic[0] == 0) //セイバー { SelectMagic[stockMagic[0]].SendMessage("Fire"); break; } if (stockMagic[0] == 3) //ボム { SelectMagic[stockMagic[0]].SendMessage("Fire"); break; } if (stockMagic[0] != 100) //それ以外 { SelectMagic[stockMagic[0]].SendMessage("Fire"); //DisplaceStockMagic(); } } if (!right) //左トリガーでバリア { if (!flag_defence) { SelectMagic[5].SendMessage("Fire"); flag_defence = true; } } } break; case VRButton.TriggerUp: if (Pz.GetF_Magic()) //魔法が打てる状態かどうかを確認 { if (right) { /* * if (stockMagic[0] == 0)//バブル * { * //使用済み * DisplaceStockMagic(); * break; * } * if (stockMagic[0] == 1)//セイバー * { * //剣を壊す * SelectMagic[stockMagic[0]].SendMessage("Break"); * DisplaceStockMagic(); * Debug.Log("www"); * break; * } * if (stockMagic[0] == 4)//ボム * { * //ボムを投げる * SelectMagic[stockMagic[0]].SendMessage("Throw"); * DisplaceStockMagic(); * break; * } * if (stockMagic[0] == 6)//ブーメラン * { * //投げる * SelectMagic[stockMagic[0]].SendMessage("Throw"); * DisplaceStockMagic(); * break; * } */ if (stockMagic[0] == 0) //セイバー { //剣を壊す SelectMagic[stockMagic[0]].SendMessage("Break"); DisplaceStockMagic(); break; } if (stockMagic[0] == 3) //ボム { //ボムを投げる SelectMagic[stockMagic[0]].SendMessage("Throw"); DisplaceStockMagic(); break; } if (stockMagic[0] != 100) //それ以外 { //SelectMagic[stockMagic[0]].SendMessage("Fire"); DisplaceStockMagic(); } } } break; case VRButton.GripDown: if (!right) //左グリップで魔法陣発動 { //if (!TriggerPress)//セイバー使ってる時に暴発しないように //{ // flag_Jin = true; //} //flag_Jin = false; //if (MagicList.Count > 0) //{ // CheckMagicList();//ここで魔法が完成しているかを判定 // SelectMagic[stockMagic[0]].SendMessage("Guide");//ガイドのある魔法はこれ使う //} } break; case VRButton.GripUp: if (!right) //左グリップ離して魔法陣しまう { //flag_Jin = false; //if(MagicList.Count > 0) //{ // CheckMagicList();//ここで魔法が完成しているかを判定 //} } break; } }
public static bool Get(VRButton input) { return(Input.GetAxisRaw(input.ToString()) > 0); }
protected override void OnButtonDown(VRButton button) { //Debug.Log("click"); //PlayerMover.Instance.SetTargetPosition(transform.position, this); }
protected virtual void OnButtonUp(VRButton button) { }
protected override void OnButtonDown(VRButton button) { //scaleTarget = 1.2f; }
private void Click(VRButton btn) { clickedFrame = Time.frameCount; if(clickSound){ if(UISounds.Instance != null){ UISounds.Instance.PlayClick(); } } OnButtonDown(btn); }
protected virtual void OnButtonDown(VRButton button) { }
protected virtual void OnButtonHeld(VRButton button) { }