123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
-
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Events;
- using System;
- public class iTweenValueTo : iTweenEditor {
- public float valueFrom = 0.0f;
- public float valueTo = 1.0f;
- [System.Serializable]
- public class OnStart : UnityEvent { };
- public OnStart onStart;
- [System.Serializable]
- public class OnUpdate : UnityEvent<float> { };
- public OnUpdate onUpdate;
- [System.Serializable]
- public class OnComplete : UnityEvent { };
- public OnComplete onComplete;
-
- void Awake() {
- if ( this.autoPlay )
- this.iTweenPlay();
- }
- public override void iTweenPlay() {
- Hashtable ht = new Hashtable();
- ht.Add( "from", this.valueFrom );
- ht.Add( "to", this.valueTo );
- ht.Add( "time", this.tweenTime );
- ht.Add( "delay", this.waitTime );
- ht.Add( "looptype", this.loopType );
- ht.Add( "easetype", this.easeType );
- ht.Add( "onstart", (Action<object>)( newVal => {
- if ( onStart != null ) {
- onStart.Invoke();
- }
- if ( onUpdate != null ) {
- onUpdate.Invoke( this.valueFrom );
- }
- } ) );
- ht.Add( "onupdate", (Action<object>)( newVal => {
- if ( onUpdate != null ) {
- onUpdate.Invoke( (float)newVal );
- }
- } ) );
- ht.Add( "oncomplete", (Action<object>)( newVal => {
- if ( onComplete != null ) {
- onComplete.Invoke();
- }
- } ) );
- ht.Add( "ignoretimescale", ignoreTimescale );
- iTween.ValueTo( this.gameObject, ht );
- }
- }
|