using UnityEngine;
/// <summary>
/// Tween the panels's alpha.
/// </summary>
[AddComponentMenu("NGUI/Tween/PanelAlpha")]
public class TweenPanelAlpha : UITweener
{
public float from = 1f;
public float to = 1f;
Transform mTrans;
UIPanel mPanel;
/// <summary>
/// Current alpha.
/// </summary>
public float alpha { get { return mPanel.alpha; } set { mPanel.alpha = value; } }
/// <summary>
/// Find all needed components.
/// </summary>
void Awake () { mPanel = GetComponentInChildren<UIPanel>(); }
/// <summary>
/// Interpolate and update the alpha.
/// </summary>
override protected void OnUpdate (float factor, bool isFinished) { alpha = Mathf.Lerp(from, to, factor); }
/// <summary>
/// Start the tweening operation.
/// </summary>
static public TweenAlpha Begin (GameObject go, float duration, float alpha)
{
TweenAlpha comp = UITweener.Begin<TweenAlpha>(go, duration);
comp.from = comp.alpha;
comp.to = alpha;
return comp;
}
}