using System; using UnityEngine; [RequireComponent(typeof(Camera))] [AddComponentMenu("NGUI/Tween/Tween Field of View")] public class TweenFOV : UITweener { public Camera cachedCamera { get { if (this.mCam == null) { this.mCam = base.GetComponent(); } return this.mCam; } } [Obsolete("Use 'value' instead")] public float fov { get { return this.value; } set { this.value = value; } } public float value { get { return this.cachedCamera.fieldOfView; } set { this.cachedCamera.fieldOfView = value; } } protected override void OnUpdate(float factor, bool isFinished) { this.value = this.from * (1f - factor) + this.to * factor; } public static TweenFOV Begin(GameObject go, float duration, float to) { TweenFOV tweenFOV = UITweener.Begin(go, duration); tweenFOV.from = tweenFOV.value; tweenFOV.to = to; if (duration <= 0f) { tweenFOV.Sample(1f, true); tweenFOV.enabled = false; } return tweenFOV; } [ContextMenu("Set 'From' to current value")] public override void SetStartToCurrentValue() { this.from = this.value; } [ContextMenu("Set 'To' to current value")] public override void SetEndToCurrentValue() { this.to = this.value; } [ContextMenu("Assume value of 'From'")] private void SetCurrentValueToStart() { this.value = this.from; } [ContextMenu("Assume value of 'To'")] private void SetCurrentValueToEnd() { this.value = this.to; } public float from = 45f; public float to = 45f; private Camera mCam; }