public bool OnFingerPinchMove(Vector2 fingerPos1, Vector2 fingerPos2, float delta) { return(false); if (!_isPitching) { return(true); } OnFingerPinchMove_imple(delta); if (!HelpUtil.FloatEquals(Globals.Instance.MSceneManager.mMainCamera.transform.localPosition.y, DefaultCameraHeight) && !mIsCameraMoveDefaultState) { mIsCameraMoveDefaultState = true; MoveCameraDefault(true, delegate() { mIsCameraMoveDefaultState = false; }); } return(true); }
// Test the Line segment is intersect with Rect public static bool Intersect(Rect rect, Vector3 a, Vector3 b, out Vector3 crossPoint) { crossPoint = Vector3.zero; // All inside if ((rect.Contains(a) && rect.Contains(b)) || (!rect.Contains(a) && !rect.Contains(b))) { return(false); } if ((rect.Contains(a) && !rect.Contains(b)) || (rect.Contains(b) && !rect.Contains(a))) { if (HelpUtil.FloatEquals(a.x, b.x)) { crossPoint.x = b.x; if (b.y > rect.yMax) { crossPoint.y = rect.yMax; } else { crossPoint.y = rect.yMin; } } else if (HelpUtil.FloatEquals(a.y, b.y)) { crossPoint.y = b.y; if (b.x > rect.xMax) { crossPoint.x = rect.xMax; } else { crossPoint.x = rect.xMin; } } else { // line : // kx+c=y // float k = (b.y - a.y) / (b.x - a.x); float k1 = rect.height / rect.width; float c = b.y - (k * b.x); if (k > 0) { if (k > k1) { if (b.x > a.x) { crossPoint.x = (rect.yMax - c) / k; crossPoint.y = rect.yMax; } else { crossPoint.x = (rect.yMin - c) / k; crossPoint.y = rect.yMin; } } else { if (b.x > a.x) { crossPoint.x = rect.xMax; crossPoint.y = k * rect.xMax + c; } else { crossPoint.x = rect.xMin; crossPoint.y = k * rect.xMin + c; } } } else { if (Mathf.Abs(k) > k1) { if (b.x > a.x) { crossPoint.x = (rect.yMin - c) / k; crossPoint.y = rect.yMin; } else { crossPoint.x = (rect.yMax - c) / k; crossPoint.y = rect.yMax; } } else { if (b.x > a.x) { crossPoint.x = rect.xMax; crossPoint.y = k * rect.xMax + c; } else { crossPoint.x = rect.xMin; crossPoint.y = k * rect.xMin + c; } } } } return(true); } return(false); }