private void Awake() { DontDestroyOnLoad(gameObject); OVRPlugin.Handedness handedness = OVRPlugin.GetDominantHand(); Instantiate(controller, universalAnchor.transform); switch (handedness) { case OVRPlugin.Handedness.LeftHanded: universalAnchor.transform.parent = leftAnchor.transform; break; case OVRPlugin.Handedness.RightHanded: case OVRPlugin.Handedness.Unsupported: universalAnchor.transform.parent = rightAnchor.transform; break; default: throw new System.NotImplementedException(); } }
// Update is called once per frame void Update() { OVRPlugin.Handedness handedness = OVRPlugin.GetDominantHand(); if (handedness == OVRPlugin.Handedness.RightHanded && !RightHanded) { transform.parent = Rhand.transform; transform.localPosition = new Vector3(0, 0, 0); transform.localRotation = Quaternion.identity; RightHanded = true; } else if (handedness == OVRPlugin.Handedness.LeftHanded && RightHanded) { transform.parent = Lhand.transform; transform.localPosition = new Vector3(0, 0, 0); transform.localRotation = Quaternion.identity; RightHanded = false; } bool left = OVRInput.GetDown(OVRInput.Button.DpadLeft) || OVRInput.GetDown(OVRInput.Button.Left) || Input.GetKeyDown(KeyCode.LeftArrow); bool right = OVRInput.GetDown(OVRInput.Button.DpadRight) || OVRInput.GetDown(OVRInput.Button.Right) || Input.GetKeyDown(KeyCode.RightArrow); if (left || right) { int dir = left ? -1 : 1; transform.parent.gameObject.transform.parent.gameObject.transform.Rotate(0, dir * 45f, 0); } if (OVRInput.GetDown(OVRInput.Button.Back) || Input.GetKeyDown(KeyCode.Space)) { if (UImanager.Current != null) { if (!UImanager.Current.backMenu) { UImanager.Current.backMenu = true; } else { UImanager.Current.backMenu = false; } print("detecting uimanager"); } else if (TimelineController.Current != null) { /* * if (!TimelineController.Current.backMenu) * { * TimelineController.Current.backMenu = true; * } * else * { * TimelineController.Current.backMenu = false; * } * print("detecting timelinecontroll"); */ TimelineController.Current.Menu(); } /* * else if (OfficeControl.Current != null) * { * if (!OfficeControl.Current.backMenu) * { * OfficeControl.Current.backMenu = true; * } * else * { * OfficeControl.Current.backMenu = false; * } * print("detecting office"); * } * else if (LzControl.Current != null) * { * if (!LzControl.Current.backMenu) * { * LzControl.Current.backMenu = true; * } * else * { * LzControl.Current.backMenu = false; * } * print("detecting lz"); * } */ /* * else if (Home_Menu_Control.Current != null) * { * Home_Menu_Control.Current.Revert(); * } */ else { if (BackMenu.Current != null) { if (BackMenu.Current.isActiveAndEnabled) { BackMenu.Current.Close(); print("tryin to close"); } else { BackMenu.Current.gameObject.SetActive(true); print("tryin to open"); } } } } Vector3 fwd = transform.forward; RaycastHit hit; if (Physics.Raycast(this.transform.position, fwd, out hit, 50)) { target = hit.transform; line.SetPosition(0, new Vector3(0, 0, Vector3.Distance(hit.transform.position, this.transform.position))); if (target.gameObject == picQuad || target.gameObject.GetComponent <PicQuad>()) { if (!camStop) { if (Input.GetMouseButtonDown(0) || OVRInput.GetDown(OVRInput.Button.One) || OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch)) { StartCoroutine(Photo()); } if (!camUp) { camUI.SetActive(true); camUp = true; } if (camUI.transform.localPosition.y <= camPos.y - 0.001f) { camUI.transform.Translate(Vector3.up * Time.deltaTime * 0.6f); } else if (camUI.transform.localPosition.y > camPos.y) { camUI.transform.localPosition = new Vector3(camPos.x, camPos.y, camPos.z); } } line.SetPosition(0, new Vector3(0, 0, 0)); return; } else { if (camUI != null) { if (camUI.transform.localPosition.y >= camPos.y - .2f) { camUI.transform.Translate(Vector3.down * Time.deltaTime * 1); } else if (camUp) { camUI.SetActive(false); camUp = false; } } } if (target.gameObject != null) { } if (PreviousSelection != target.gameObject) { if (PreviousSelection != null) { PreviousSelection.GetComponent <ButtonReq>().highlighted = false; PreviousSelection.GetComponent <ButtonReq>().pressed = false; audioPlayed = false; } if (target.gameObject.GetComponent <ButtonReq>()) { PreviousSelection = target.gameObject; } } if (target.gameObject.GetComponent <ButtonReq>()) { /* * if(target.GetComponent<ButtonReq>().highlighted == false) * { * HoverAudioSource.Play(); * } */ if (!audioPlayed) { if (target.gameObject.GetComponent <Highlightable>() != null) { if (target.gameObject.GetComponent <Highlightable>().gameStateDepend == true) { if (target.gameObject.GetComponent <Highlightable>().gamStat == target.gameObject.GetComponent <Highlightable>().gameStateNeeded) { //highlighting = true; HoverAudioSource.Play(); audioPlayed = true; } } } else { //highlighting = true; HoverAudioSource.Play(); audioPlayed = true; } } target.GetComponent <ButtonReq>().highlighted = true; } /* * if (target.gameObject.GetComponent<ButtonScript>()) * { * } * if (target.gameObject.GetComponent<InterfaceButtons>()) * { * target.gameObject.GetComponent<InterfaceButtons>().highlighted = true; * } */ //edited out if (Input.GetMouseButtonDown(0) || OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch)) { if (target.gameObject.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().pressed = true; } if (pressable) { if (target.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().ButtonActivated(); pressable = false; ClickAudioSource.Play(); } } } //ENABLE IF NOT MOVABLE if (!moveable) { if (OVRInput.GetDown(OVRInput.Button.One)) { if (target.gameObject.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().pressed = true; } if (pressable) { if (target.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().ButtonActivated(); pressable = false; ClickAudioSource.Play(); } } } if (OVRInput.GetDown(OVRInput.Button.One)) { if (target.gameObject.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().pressed = false; } pressable = true; } } else if (moveable) { if (OVRInput.GetDown(OVRInput.Button.One)) { teleDown = true; } if (OVRInput.GetUp(OVRInput.Button.One) && teleDown) { StartCoroutine(MoveHint()); teleDown = false; } } //edited out || OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch) if (Input.GetMouseButtonUp(0) || OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch)) { if (target.gameObject.GetComponent <ButtonReq>()) { target.GetComponent <ButtonReq>().pressed = false; } pressable = true; } } else { line.SetPosition(0, new Vector3(0, 0, 20)); if (target != null) { if (target.GetComponent <ButtonReq>() != null) { target.GetComponent <ButtonReq>().pressed = false; } } pressable = true; if (PreviousSelection != null) { PreviousSelection.GetComponent <ButtonReq>().highlighted = false; PreviousSelection.GetComponent <ButtonReq>().pressed = false; PreviousSelection = null; } audioPlayed = false; } }