void Start() { _object_to_rotate = null; _tState = TOUCHSTATE.UNTOUCH; _touchCount = 0; _touch_1_time = 0f; _touch_2_time = 0f; _double_Tap = false; _doorOpen = false; _itemsShown = false; _shownSits = false; _wardrobe_animator = Wardrobe.GetComponent <Animator>(); _coffeeTable_animator = Coffeetable.GetComponent <Animator>(); Close_all_anim_icons(); Message.text = "Double Tap to Place"; ZapparCamera.Instance.RegisterCameraListener(this); }
void TouchUpdate() { switch (_tState) { case TOUCHSTATE.UNTOUCH: if (Input.touchCount > 0) { _tState = TOUCHSTATE.ONTOUCH; } else { if (_single_Tap) { _single_Tap = false; if (!_double_Tap) { _touch_1_time = Time.time; _double_Tap = true; } //add single tap functions } else { _object_to_rotate = null; } } break; case TOUCHSTATE.ONTOUCH: if (Input.touchCount == 1) { if (!_single_Tap) { _single_Tap = true; if (Input.touches[0].phase == TouchPhase.Moved) { //add touch and drag functions } } else if (_double_Tap) { if (Time.time - _touch_1_time < 2f) { //add double tap functions m_userHasPlaced = !m_userHasPlaced; LoadingBar.SetActive(!m_userHasPlaced); Message.text = (m_userHasPlaced == false) ? "Double Tap to Place" : "Double Tap to Move"; //add object to rotate //_object_to_rotate = someobject; } _double_Tap = false; } } else if (Input.touchCount == 2) { if (Input.touches[1].phase == TouchPhase.Began) { _diff_Start = Vector3.Distance(Input.touches[1].position, Input.touches[0].position); } if (_object_to_rotate != null) { if (Input.touches[0].phase == TouchPhase.Moved || Input.touches[1].phase == TouchPhase.Moved) { //add objects rotation code //hold this } } else { if (Input.touches[0].phase == TouchPhase.Moved || Input.touches[1].phase == TouchPhase.Moved) { _diff_move = Vector3.Distance(Input.touches[1].position, Input.touches[0].position); if (_diff_move > _diff_Start) //pinch out { if (Objects.transform.localScale.y < ScaleRange.y) { Objects.transform.localScale += new Vector3(1f, 1f, 1f) * Time.deltaTime * 0.5f; } _diff_Start = _diff_move; } else if (_diff_move < _diff_Start) //pinch in { if (Objects.transform.localScale.y > ScaleRange.x) { Objects.transform.localScale -= new Vector3(1f, 1f, 1f) * Time.deltaTime * 0.5f; } _diff_Start = _diff_move; } else { } } } } else { _tState = TOUCHSTATE.UNTOUCH; } break; } }