using UnityEngine;
using System.Collections;

namespace uTools
{
    public class uTweenTextMeshAlpha : uTweenValue
    {
        TextMesh m_textMesh;

        TextMesh textMesh
        {
            get
            {
                if (null == m_textMesh)
                {
                    m_textMesh = GetComponent<TextMesh>();
                }
                return m_textMesh;
            }
        }

        float m_alpha;

        float alpha
        {
            get
            {
                return m_alpha;
            }
            set
            {
                SetAlpha(textMesh, value);
                m_alpha = value;
            }
        }

        protected override void ValueUpdate(float value, bool isFinished)
        {
            alpha = value;
        }

        void SetAlpha(TextMesh _text, float _alpha)
        {
            Color c = Color.white;
            c = _text.color;
            c.a = _alpha;
            _text.color = c;
        }
    }
}
