// This gets called in response to a gesture event. private void ProcessGesture(Gesture gesture) { if (m_instructions.activeSelf) { m_instructions.SetActive(false); } Vector3 v = CUtil.ClosestAxis(gesture.m_dirDevice); float duration = 0.6f; if (v == Vector3.left) { m_left.Begin(duration); } if (v == Vector3.right) { m_right.Begin(duration); } if (v == Vector3.back) { m_back.Begin(duration); } if (v == Vector3.forward) { m_forward.Begin(duration); } if (v == Vector3.down) { m_down.Begin(duration); } if (v == Vector3.up) { m_up.Begin(duration); } }
private void ProcessGesture(Gesture gesture) { if (catched) { return; } t.text = gesture.m_dirDevice.ToString(); Vector3 v = CUtil.ClosestAxis(gesture.m_dirDevice); if (isCatchPossible && v == Vector3.back) { if (c) { c.gameObject.transform.parent = gameObject.Child("cubeCase").transform; c.gameObject.transform.position = gameObject.Child("cubeCase").transform.position; catched = true; Observable.Timer(System.TimeSpan.FromSeconds(5f)) .Subscribe(_ => { c.gameObject.transform.parent = null; c.GetComponent <Rigidbody>().velocity = Vector3.zero; c.transform.position = new Vector3(0, -2.5f, 2f); c = null; catched = false; }); } p.SetActive(true); Invoke("endT", 3f); } }
private IEnumerator CoAnimateGesture(Gesture gesture, float timeSecs) { Vector3 v = Vector3.zero; switch (m_coordSys) { case 0: v = gesture.m_dirDevice; break; case 1: v = gesture.m_dirWorldXZ; break; case 2: v = gesture.m_dirWorldXYZ; break; } if (m_snapToAxisToggle.isOn) { v = CUtil.ClosestAxis(v); } Transform rod = m_gestureRodPool.Take(); rod.localRotation = Quaternion.LookRotation(v) * Quaternion.Euler(-90, 0, 0); float startTime = Time.time; float elapsed = 0f; while ((elapsed = Time.time - startTime) < timeSecs) { float pct = elapsed / timeSecs; float size = 1f; if (pct < 0.25f) // Grow { size = pct * 4f; } else if (pct >= 0.75f) // Shrink { size = (1f - pct) * 4f; } rod.localScale = new Vector3(0.1f, v.magnitude * size / 2f, 0.1f); rod.localPosition = v * size / 2f; yield return(null); } rod.localPosition = Vector3.zero; rod.localScale = Vector3.zero; m_gestureRodPool.Return(rod); }