void Update() { VoiceMgr vm = VoiceMgr.GetInstance(); float now = Time.time; if (Input.GetMouseButtonDown(0)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject ob = hit.collider.gameObject; if (ob.Equals(button)) { enter(TOUCH_STATE.START); inButton = true; draging = true; } } } if (draging) { bool found = false; Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject ob = hit.collider.gameObject; if (ob.Equals(button)) { found = true; } } if (Input.GetMouseButtonUp(0)) { enter(found ? TOUCH_STATE.END : TOUCH_STATE.CANCEL); draging = false; } else if (draging) { if (found != inButton) { enter(found ? TOUCH_STATE.MOVE_IN : TOUCH_STATE.MOVE_OUT); inButton = found; } } } if (voice.activeSelf && volume.activeSelf) { if (now - lastCheckTime > 0.3f) { int v = vm.getVoiceLevel(5); for (int i = 0; i < volumes.Length; i++) { volumes [i].SetActive(v > i); } lastCheckTime = now; } } if (lastTouchTime > 0) { long t = (long)((Time.time - lastTouchTime) * 1000); if (t >= MAXTIME) { onVoiceOK(); lastTouchTime = 0; } else { time.transform.localScale = new Vector2((float)t / MAXTIME, 1); } } }