Beispiel #1
0
 /*  Restart
  *      Restart animation.
  */
 public void Restart()
 {
     SetDelay(delay);
     if (!UIAnimator.Animations.Contains(this))
     {
         UIAnimator.AddAnimation(this);
     }
 }
        public UIBezierAnimation(RectTransform transform, Vector2 origin, Vector2 target, float duration, Vector2 p1) : base(transform, origin, target, duration)
        {
            float   canvasScale = (UIAnimator.ScaleWithScreen) ? UIAnimator.FindObjectOfType <Canvas>().scaleFactor : 1;
            Vector2 mP0         = Vector2.Scale(origin, UIAnimator.ScreenDimension) - (Vector2)transform.position / canvasScale + transform.anchoredPosition;
            Vector2 mP1         = Vector2.Scale(p1, UIAnimator.ScreenDimension) - (Vector2)transform.position / canvasScale + transform.anchoredPosition;
            Vector2 mP2         = Vector2.Scale(target, UIAnimator.ScreenDimension) - (Vector2)transform.position / canvasScale + transform.anchoredPosition;

            effectBehaviour = Effect.BezierEffectBehaviour(mP0, mP1, mP2);
        }
Beispiel #3
0
 /*  Awake, Start, Update
  *      Unity functions.
  *      Update is called each frame. It
  *      updates all unfinished animations.
  */
 void Awake()
 {
     if (instance == null)
     {
         instance                = this;
         animations              = new List <UIAnimation>();
         removeList              = new List <UIAnimation>();
         screenDimension         = new Vector2(Screen.width, Screen.height);
         invertedScreenDimension = new Vector2(1f / Screen.width, 1f / Screen.height);
     }
 }
 /*  Awake, Start, Update
  *      Unity functions.
  *      Update is called each frame. It
  *      updates all unfinished animations.
  */
 void Awake()
 {
     if (instance == null)
     {
         instance   = this;
         animations = new List <UIAnimation>();
         removeList = new List <UIAnimation>();
         try
         {
             scaleWithScreen         = FindObjectOfType <CanvasScaler>().uiScaleMode == CanvasScaler.ScaleMode.ScaleWithScreenSize;
             screenDimension         = /*new Vector2(canvasRect.rect.width, canvasRect.rect.height);//*/ new Vector2(Screen.width, Screen.height);
             invertedScreenDimension = new Vector2(1f / screenDimension.x, 1f / screenDimension.y);
         } catch (System.NullReferenceException) {
             Debug.Log("Please, add a Canvas to your scene");
         }
     }
 }
        public UIPositionAnimation(RectTransform transform, Vector2 origin, Vector2 target, float duration)
        {
            Canvas canvas      = UIAnimator.FindObjectOfType <Canvas>();
            float  canvasScale = (UIAnimator.ScaleWithScreen) ? 1 / canvas.scaleFactor : 1;

            this.transform = transform;
            this.duration  = duration < 0.0000001f ? 0.0000001f : duration;
            Vector2 position = (canvas.renderMode == RenderMode.ScreenSpaceCamera) ? canvas.worldCamera.WorldToScreenPoint(transform.position) : transform.position;

            this.originPosition = Vector2.Scale(origin, UIAnimator.ScreenDimension) * canvasScale - position * canvasScale + transform.anchoredPosition;
            this.targetPosition = Vector2.Scale(target, UIAnimator.ScreenDimension) * canvasScale - position * canvasScale + transform.anchoredPosition;
            updateBehaviour     = Modifier.Linear;
            effectBehaviour     = Effect.NoEffect;
            //DEBUG

            /*
             * Debug.Log("Screen Dimention: " + UIAnimator.ScreenDimension);
             * Debug.Log("Canvas Scale: " + canvasScale);
             * Debug.Log("Origin: " + this.originPosition + " (" + Vector2.Scale(origin, UIAnimator.ScreenDimension) + " - " + position + " + " + transform.anchoredPosition + ")");
             * Debug.Log("Target: " + this.targetPosition + " (" + Vector2.Scale(target, UIAnimator.ScreenDimension) + " - " + position + " + " + transform.anchoredPosition + ")");
             */
        }
Beispiel #6
0
 /*  Stop
  *      Stop animation.
  */
 public void Stop()
 {
     UIAnimator.RemoveAnimation(this);
 }