private bool AnimProperty(FloatTween prop, CameraParameter para, bool chechAngle)
        {
            if (para == null || prop == null)
            {
                return(false);
            }
            float value = para.value;

            if (chechAngle && para.isAngle)
            {
                float pt = prop.To;
                while (pt > 180f)
                {
                    pt -= 360f; prop.Value -= 360f;
                }
                while (pt < -180f)
                {
                    pt += 360f; prop.Value += 360f;
                }
                while (value - pt > 180f)
                {
                    value -= 360f;
                }
                while (value - pt < -180f)
                {
                    value += 360f;
                }
            }
            return(para.curve != null?
                   prop.AnimTo(value, para.duration, para.curve) :
                       prop.AnimTo(value, para.duration, para.ease));
        }
 public static void Cache(CameraParameter para)
 {
     if (para == null)
     {
         return;
     }
     para.curve = null;
     cached_instances.Enqueue(para);
 }
        public static CameraParameter Get(float value, float duration, AnimationCurve curve)
        {
            CameraParameter ins = cached_instances.Count > 0 ? cached_instances.Dequeue() : new CameraParameter();

            ins.value    = value;
            ins.duration = duration;
            ins.ease     = Ease.eEaseType.Linear;
            ins.curve    = curve;
            ins.isAngle  = false;
            return(ins);
        }
 public void ResetView(float duration, Ease.eEaseType ease)
 {
     if (mViewInited)
     {
         AnimProperty(mRotY, CameraParameter.Get(DefaultRotY, duration, ease), true);
         AnimProperty(mLookDown, CameraParameter.Get(DefaultLookDown, duration, ease), true);
         mDistance.AnimTo(DefaultDistance, duration, ease);
         mCamFovOrSize.AnimTo(DefaultCamFovOrSize, duration, ease);
         mPropTweening = true;
     }
     else
     {
         mViewInited         = true;
         mRotY.Value         = DefaultRotY;
         mLookDown.Value     = DefaultLookDown;
         mDistance.Value     = DefaultDistance;
         mCamFovOrSize.Value = DefaultCamFovOrSize;
         FlushCamera();
     }
 }
 public void ChangeView(CameraParameter rotY, CameraParameter lookDown, CameraParameter distance, CameraParameter fovOrSize)
 {
     if (mViewInited)
     {
         bool b1 = AnimProperty(mRotY, rotY, true);
         bool b2 = AnimProperty(mLookDown, lookDown, true);
         bool b3 = AnimProperty(mDistance, distance, false);
         bool b4 = AnimProperty(mCamFovOrSize, fovOrSize, false);
         if (!b1 || !b2 || !b3 || !b4)
         {
             mPropTweening = true;
         }
     }
     else
     {
         mViewInited         = true;
         mRotY.Value         = rotY.value;
         mLookDown.Value     = lookDown.value;
         mDistance.Value     = distance.value;
         mCamFovOrSize.Value = fovOrSize.value;
     }
     FlushCamera();
 }