123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using UnityEngine;
- [AddComponentMenu("NGUI/Tween/Tween Scale")]
- public class TweenScale : UITweener
- {
- public Transform cachedTransform
- {
- get
- {
- if (this.mTrans == null)
- {
- this.mTrans = base.transform;
- }
- return this.mTrans;
- }
- }
- public Vector3 value
- {
- get
- {
- return this.cachedTransform.localScale;
- }
- set
- {
- this.cachedTransform.localScale = value;
- }
- }
- [Obsolete("Use 'value' instead")]
- public Vector3 scale
- {
- get
- {
- return this.value;
- }
- set
- {
- this.value = value;
- }
- }
- protected override void OnUpdate(float factor, bool isFinished)
- {
- this.value = this.from * (1f - factor) + this.to * factor;
- if (this.updateTable)
- {
- if (this.mTable == null)
- {
- this.mTable = NGUITools.FindInParents<UITable>(base.gameObject);
- if (this.mTable == null)
- {
- this.updateTable = false;
- return;
- }
- }
- this.mTable.repositionNow = true;
- }
- }
- public static TweenScale Begin(GameObject go, float duration, Vector3 scale)
- {
- TweenScale tweenScale = UITweener.Begin<TweenScale>(go, duration);
- tweenScale.from = tweenScale.value;
- tweenScale.to = scale;
- if (duration <= 0f)
- {
- tweenScale.Sample(1f, true);
- tweenScale.enabled = false;
- }
- return tweenScale;
- }
- [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 Vector3 from = Vector3.one;
- public Vector3 to = Vector3.one;
- public bool updateTable;
- private Transform mTrans;
- private UITable mTable;
- }
|