1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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<Camera>();
- }
- 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<TweenFOV>(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;
- }
|