void Update() { #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Tab)) { this.TriggerSwitch(); } #endif if (this.m_IsMoving) { if (this.m_TowardOnTable) { this.m_Timer += Time.deltaTime; if (this.m_Timer >= this.m_LerpDuration) { // On Table this.m_IsMoving = false; this.transform.position = this.onTable.position; this.transform.rotation = this.onTable.rotation; this.castable = true; } else { this.transform.position = this.inHand.position + (this.onTable.position - this.inHand.position) * this.m_Timer / this.m_LerpDuration; this.transform.rotation = Quaternion.Slerp(this.inHand.rotation, this.onTable.rotation, this.m_Timer / this.m_LerpDuration); } } else { this.m_Timer -= Time.deltaTime; if (this.m_Timer <= 0) { // In Hand this.m_IsMoving = false; this.transform.position = this.inHand.position; this.transform.rotation = this.inHand.rotation; this.screenCanvas.renderMode = RenderMode.ScreenSpaceCamera; RealityManager.OnBackToAppFinished(); } else { this.transform.position = this.inHand.position + (this.onTable.position - this.inHand.position) * this.m_Timer / this.m_LerpDuration; this.transform.rotation = Quaternion.Slerp(this.inHand.rotation, this.onTable.rotation, this.m_Timer / this.m_LerpDuration); } } } }
void Awake() { if (instance == null || instance != this) { instance = this; } Debug.Assert(this.phone); Debug.Assert(this.viewer); }
void Update() { if (this.m_EnableToCastRay) { if (Input.touchCount > 0) { // Debug.Log("Touch"); var touch = Input.GetTouch(0); Ray mouseDownCheckRay = Camera.main.ScreenPointToRay(touch.position); RaycastHit hitInfo; if (Physics.Raycast(mouseDownCheckRay, out hitInfo, Mathf.Infinity)) { // Debug.Log(hitInfo.transform.name); if (hitInfo.transform.name == "Phone") { RealityManager.TriggerSwitch(); } } } if (Input.GetMouseButtonDown(0)) { // Debug.Log("Mouse Down"); Ray mouseDownCheckRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(mouseDownCheckRay, out hitInfo, Mathf.Infinity)) { // Debug.Log(hitInfo.transform.name); if (hitInfo.transform.name == "Phone") { RealityManager.TriggerSwitch(); } } } } if (Input.GetKeyDown(KeyCode.Tab)) { this.TriggerSwitch(); } if (this.m_IsMoving) { if (this.m_TowardOnTable) { this.m_Timer += Time.deltaTime; if (this.m_Timer >= this.m_LerpDuration) { // On Table this.m_IsMoving = false; this.m_IsOnTable = true; this.m_IsInHand = false; this.transform.position = this.onTable.position; this.transform.rotation = this.onTable.rotation; this.m_EnableToCastRay = true; } else { this.transform.position = this.inHand.position + (this.onTable.position - this.inHand.position) * this.m_Timer / this.m_LerpDuration; this.transform.rotation = Quaternion.Slerp(this.inHand.rotation, this.onTable.rotation, this.m_Timer / this.m_LerpDuration); } } else { this.m_Timer -= Time.deltaTime; if (this.m_Timer <= 0) { // In Hand this.m_IsMoving = false; this.m_IsOnTable = false; this.m_IsInHand = true; this.transform.position = this.inHand.position; this.transform.rotation = this.inHand.rotation; this.screenCanvas.renderMode = RenderMode.ScreenSpaceCamera; RealityManager.OnBackToAppFinished(); } else { this.transform.position = this.inHand.position + (this.onTable.position - this.inHand.position) * this.m_Timer / this.m_LerpDuration; this.transform.rotation = Quaternion.Slerp(this.inHand.rotation, this.onTable.rotation, this.m_Timer / this.m_LerpDuration); } } } }