public static Vector3 GetDeltaPosition() { if (IsPC) { UnityTouchPhase phase = GetPhase(); if (phase != UnityTouchPhase.None) { Vector3 now = Input.mousePosition; Vector3 delta = now - beforePosition; beforePosition = now; return(delta); } } else { if (Input.touchCount > 0) { return(Input.GetTouch(0).deltaPosition); } } return(Vector3.zero); }
public void CheckTouch() { Vector3 p_pos = UnityTouch.GetPosition(); // ピクセル座標 Vector2 u_pos = main_camera.ScreenToWorldPoint(p_pos); // Unity座標 UnityTouchPhase phase = UnityTouch.GetPhase(); if (phase == UnityTouchPhase.None) { return; } else if (phase == UnityTouchPhase.Began) { if (Mathf.Abs(u_pos.x) >= 2.7f || Mathf.Abs(u_pos.y) >= 3.3f) { puzzleManager.ChangeState(PuzzleState.Wait); return; } puzzleManager.ChangeState(); } else if (phase == UnityTouchPhase.Ended) { puzzleManager.ChangeState(); return; } if (puzzleManager.GetState() == PuzzleState.Touch) { if (Mathf.Abs(u_pos.x) >= 2.7f || Mathf.Abs(u_pos.y) >= 3.3f) { puzzleManager.ChangeState(); return; } } for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { GlobeObject g_obj = globeArray[i, j].Object.SafeGetComponent <GlobeObject>(); if (g_obj.IsTouch(u_pos)) { // 既にタッチしたGlobeの処理 if (globeArray[i, j].IsTouch) { // 直前に触れたGlobeは処理しない if (touchedStack.Count != 0 && touchedStack.Peek() == new Vector2(i, j)) { return; } else { puzzleManager.ChangeState(); return; } } g_obj.DoTouch(); // Globeの色を変える globeArray[i, j].DoTouch(); // IsTouch = true touchedStack.Push(new Vector2(i, j)); } } } }