/// <summary> /// Handles button down event. /// </summary> /// <param name="buttonNum">The button pressed</param> /// <param name="origin">The position of the tracker</param> /// <param name="direction">The forward direction of the tracker</param> /// <param name="hit">The object hit with raycast.</param> public void ButtonDown(TrackerButton buttonNum, Vector3 origin, Vector3 direction, RaycastHit hit) { if (buttonNum == TrackerButton.Trigger) { objectHit = hit; } }
/// <summary> /// Handles a button click event. It checks for previous/next click or passes it on to the selected tool. Also calls driver tool for button events. /// </summary> /// <param name="button">The button clicked</param> /// <param name="origin">The tracker position</param> /// <param name="direction">The forward direction of the tracker.</param> /// <returns></returns> public bool handleButtonClick(TrackerButton button, Vector3 origin, Vector3 direction) { if (button == TrackerButton.NextTool) { NextTool(); updateToolName(tool); return(true); } else if (button == TrackerButton.PreviousTool) { PreviousTool(); updateToolName(tool); return(true); } else { try { list[toolNumber].ButtonClick(button, origin, direction); } catch (Exception e) { Debug.LogError(e); } driveTool.ButtonClick(button, origin, direction); return(true); } }
/// <summary> /// Handles a button down event /// </summary> /// <param name="button">The button dragged</param> /// <param name="hit">The object hit</param> /// <param name="origin">The tracker position</param> /// <param name="direction">The tracker forward direction.</param> /// <returns></returns> public bool handleButtonDown(TrackerButton button, RaycastHit hit, Vector3 origin, Vector3 direction) { try { list[toolNumber].ButtonDown(button, origin, direction, hit); } catch (Exception e) { Debug.LogError(e); } return(true); }
/// <summary> /// Takes in the button input which tells the object which way to rotate /// </summary> /// <param name="button"></param> /// <param name="origin"></param> /// <param name="direction"></param> /// <param name="isPressed"></param> public void ButtonClick(TrackerButton button, Vector3 origin, Vector3 direction) { if (button == TrackerButton.Button3) { setHorizontal(); } else if (button == TrackerButton.Button4) { setVertical(); } }
/// <summary> /// Handles the button input for the warp tool /// </summary> public void ButtonClick(TrackerButton button, Vector3 origin_, Vector3 direction_) { if (button == TrackerButton.Trigger) { Warp(origin_, direction_); } if (button == TrackerButton.Button1) { undoWarp(); } }
/// <summary> /// Asynchronous method taking in button input and sending it to the current selected tool /// </summary> /// <returns></returns> private IEnumerator Button() { int maxButtons = trackerButtonList.getMaxButtons(); while (true) { Vector3 origin = wandObject.transform.position; Vector3 direction = wandObject.transform.forward; //i tracks the number of the current button for (int i = 0; i < maxButtons; ++i) { //Current value of the button bool curValue = VRPN.vrpnButton(trackerAddress, i); TrackerButton currentButton = trackerButtonList.MapButton(i); //If the previous state is true and the current value is false it is a button click if (buttonState.ContainsKey(currentButton) && buttonState[currentButton] && !curValue) { //Fire the event toolManager.handleButtonClick(currentButton, origin, direction); //hasStarted = false; hit = new RaycastHit(); //temp; } //If the current and previous are true then it is a buttondrag event else if (buttonState.ContainsKey(currentButton) && buttonState[currentButton] && curValue && (currentButton == TrackerButton.Trigger)) { if (hit.distance > 0) { //Fire the event toolManager.handleButtonDrag(currentButton, hit, offset, origin, direction); } } //If the previous is false and the current is true else if (!(buttonState.ContainsKey(currentButton) && buttonState[currentButton]) && curValue && (currentButton == TrackerButton.Trigger)) { Physics.Raycast(origin, direction * rayLength, out hit); if (hit.distance > 0) { offset = hit.transform.position - hit.point; } toolManager.handleButtonDown(currentButton, hit, origin, direction); } //update the previous value buttonState[currentButton] = curValue; } yield return(null); } }
/// <summary> /// Handles the button input for the grabberTool /// Takes in every button and whether it is currently being pressed or not /// While pointing at the object the user can increase or decrease the size of the object /// </summary> public void ButtonClick(TrackerButton button, Vector3 origin_, Vector3 direction_) { //Check to see if the raycast has intersected with an object if ((Physics.Raycast(origin, direction, out hit))) { //Get the current scale of the object Vector3 scale = hit.transform.localScale; if (button == TrackerButton.Button2) { hit.transform.localScale = new Vector3(scale.x + scale.x / 7, scale.y + scale.y / 7, scale.z + scale.z / 7); } else if (button == TrackerButton.Button3) { hit.transform.localScale = new Vector3(scale.x - scale.x / 7, scale.y - scale.y / 7, scale.z - scale.z / 7); } } }
/// <summary> /// Handles the UI button click interactions /// </summary> /// <param name="buttonNum"></param> /// <param name="origin"></param> /// <param name="direction"></param> public void ButtonClick(TrackerButton buttonNum, Vector3 origin, Vector3 direction) { Physics.Raycast(origin, direction, out hit); Debug.Log(hit.point); if (buttonNum == TrackerButton.Trigger) { //If the object is a dropdown show or hide the menu if (hit.collider != null && hit.transform.gameObject.GetComponent <Dropdown>() != null) { Dropdown dropdown = hit.transform.gameObject.GetComponent <Dropdown>(); Debug.Log(dropdown); if (dropDownDictionary.ContainsKey(dropdown.GetInstanceID())) { dropdown.Hide(); dropDownDictionary.Remove(dropdown.GetInstanceID()); } else { dropDownDictionary.Add(dropdown.GetInstanceID(), dropdown); dropdown.onValueChanged.AddListener((e) => { ValueChanged(dropdown, e); }); dropdown.Show(); } } //If the object is a dropdown menu selectable set that as the new dropdown value and call the method attatched else if (hit.collider != null && hit.transform.gameObject.GetComponent <Toggle>() != null) { Toggle toggle = hit.transform.gameObject.GetComponent <Toggle>(); toggle.isOn = !toggle.isOn; } //If the object is a button call the onClick method else if (hit.collider != null && hit.transform.gameObject.GetComponent <Button>() != null) { Button button = hit.transform.gameObject.GetComponent <Button>(); if (buttonNum == TrackerButton.Trigger) { button.onClick.Invoke(); } } objectHit = emptyHit; } }
public void ButtonClick(TrackerButton button, Vector3 origin, Vector3 direction) { }
/// <summary> /// Handles button down event - does nothing right now. /// </summary> /// <param name="buttonNum">The button pressed</param> /// <param name="origin">The position of the tracker</param> /// <param name="direction">The forward direction of the tracker</param> /// <param name="hit">The object hit with raycast.</param> public void ButtonDown(TrackerButton buttonNum, Vector3 origin, Vector3 direction, RaycastHit hit) { }
/// <summary> /// Handles button click - does nothing /// </summary> /// <param name="button"></param> public void ButtonClick(TrackerButton button) { throw new NotImplementedException(); }
public void ButtonClick(TrackerButton button, Vector3 origin, Vector3 direction) { //throw new NotImplementedException(); }