123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using UnityEngine;
- [RequireComponent(typeof(Camera))]
- [AddComponentMenu("NGUI/Tween/Tween Orthographic Size")]
- public class TweenOrthoSize : UITweener
- {
- public Camera cachedCamera
- {
- get
- {
- if (this.mCam == null)
- {
- this.mCam = base.GetComponent<Camera>();
- }
- return this.mCam;
- }
- }
- [Obsolete("Use 'value' instead")]
- public float orthoSize
- {
- get
- {
- return this.value;
- }
- set
- {
- this.value = value;
- }
- }
- public float value
- {
- get
- {
- return this.cachedCamera.orthographicSize;
- }
- set
- {
- this.cachedCamera.orthographicSize = value;
- }
- }
- protected override void OnUpdate(float factor, bool isFinished)
- {
- this.value = this.from * (1f - factor) + this.to * factor;
- }
- public static TweenOrthoSize Begin(GameObject go, float duration, float to)
- {
- TweenOrthoSize tweenOrthoSize = UITweener.Begin<TweenOrthoSize>(go, duration);
- tweenOrthoSize.from = tweenOrthoSize.value;
- tweenOrthoSize.to = to;
- if (duration <= 0f)
- {
- tweenOrthoSize.Sample(1f, true);
- tweenOrthoSize.enabled = false;
- }
- return tweenOrthoSize;
- }
- public override void SetStartToCurrentValue()
- {
- this.from = this.value;
- }
- public override void SetEndToCurrentValue()
- {
- this.to = this.value;
- }
- public float from = 1f;
- public float to = 1f;
- private Camera mCam;
- }
|