using UnityEngine;
using System.Collections;

namespace uTools
{
    [AddComponentMenu("uTools/Tween/Tween Size(uTools)")]
    public class uTweenSize : uTweener
    {
        public Vector2 from;
        public Vector2 to;

        RectTransform mRectTransform;

        public RectTransform cachedRectTransform { get { if (mRectTransform == null) mRectTransform = GetComponent<RectTransform>(); return mRectTransform; } }

        public Vector2 value
        {
            get
            {
                return cachedRectTransform.sizeDelta;
            }
            set
            {
                cachedRectTransform.sizeDelta = value;
            }
        }

        protected override void OnUpdate(float factor, bool isFinished)
        {
            value = from + factor * (to - from);
        }
    }
}
