//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2014 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
///
/// Tween the camera's orthographic size.
///
[RequireComponent(typeof(Camera))]
public class TweenOrthoSize : Tweener
{
public float from = 1f;
public float to = 1f;
Camera mCam;
///
/// Camera that's being tweened.
///
public Camera cachedCamera { get { if (mCam == null) mCam = GetComponent(); return mCam; } }
///
/// Tween's current value.
///
public float value
{
get { return cachedCamera.orthographicSize; }
set { cachedCamera.orthographicSize = value; }
}
///
/// Tween the value.
///
protected override void OnUpdate (float factor, bool isFinished) { value = from * (1f - factor) + to * factor; }
///
/// Start the tweening operation.
///
static public TweenOrthoSize Begin (GameObject go, float duration, float to)
{
TweenOrthoSize comp = Tweener.Begin(go, duration);
comp.from = comp.value;
comp.to = to;
if (duration <= 0f)
{
comp.Sample(1f, true);
comp.enabled = false;
}
return comp;
}
public override void SetStartToCurrentValue () { from = value; }
public override void SetEndToCurrentValue () { to = value; }
}