From 8dfd15686691aa2f3b5b3d9b3aa2bdc54059bc3a Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 2 Mar 2016 12:54:24 +0000 Subject: [PATCH] iTweenCommand.targetObject now uses GameObjectData --- .../iTween/Scripts/Commands/LookFrom.cs | 2 +- .../Fungus/iTween/Scripts/Commands/LookTo.cs | 2 +- .../Fungus/iTween/Scripts/Commands/MoveAdd.cs | 2 +- .../iTween/Scripts/Commands/MoveFrom.cs | 2 +- .../Fungus/iTween/Scripts/Commands/MoveTo.cs | 2 +- .../iTween/Scripts/Commands/PunchPosition.cs | 2 +- .../iTween/Scripts/Commands/PunchRotation.cs | 2 +- .../iTween/Scripts/Commands/PunchScale.cs | 2 +- .../iTween/Scripts/Commands/RotateAdd.cs | 2 +- .../iTween/Scripts/Commands/RotateFrom.cs | 2 +- .../iTween/Scripts/Commands/RotateTo.cs | 2 +- .../iTween/Scripts/Commands/ScaleAdd.cs | 2 +- .../iTween/Scripts/Commands/ScaleFrom.cs | 2 +- .../Fungus/iTween/Scripts/Commands/ScaleTo.cs | 2 +- .../iTween/Scripts/Commands/ShakePosition.cs | 2 +- .../iTween/Scripts/Commands/ShakeRotation.cs | 2 +- .../iTween/Scripts/Commands/ShakeScale.cs | 2 +- .../iTween/Scripts/Commands/iTweenCommand.cs | 32 +++++++++++++++---- 18 files changed, 43 insertions(+), 23 deletions(-) diff --git a/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs index cee06f50..05085917 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs @@ -48,7 +48,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.LookFrom(targetObject, tweenParams); + iTween.LookFrom(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs b/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs index d1a4fae4..2bc995d5 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs @@ -48,7 +48,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.LookTo(targetObject, tweenParams); + iTween.LookTo(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs index 6d9d5b21..6c6764c4 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs @@ -27,7 +27,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.MoveAdd(targetObject, tweenParams); + iTween.MoveAdd(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs index fadb1476..8a2aa4f2 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs @@ -37,7 +37,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.MoveFrom(targetObject, tweenParams); + iTween.MoveFrom(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs index f427c9ef..ed204e59 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs @@ -37,7 +37,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.MoveTo(targetObject, tweenParams); + iTween.MoveTo(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs index 87149a9e..c52b2f14 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs @@ -27,7 +27,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.PunchPosition(targetObject, tweenParams); + iTween.PunchPosition(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs index 89ad7991..d5a2c044 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs @@ -27,7 +27,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.PunchRotation(targetObject, tweenParams); + iTween.PunchRotation(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs index e9991768..e37ddc82 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs @@ -23,7 +23,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.PunchScale(targetObject, tweenParams); + iTween.PunchScale(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs index 7cad1509..a1e2477d 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs @@ -27,7 +27,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.RotateAdd(targetObject, tweenParams); + iTween.RotateAdd(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs index 2c33c441..bb7a219e 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs @@ -37,7 +37,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.RotateFrom(targetObject, tweenParams); + iTween.RotateFrom(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs index 5f10f21d..4e2950e1 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs @@ -37,7 +37,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.RotateTo(targetObject, tweenParams); + iTween.RotateTo(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs index 2aca66aa..772239b7 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs @@ -23,7 +23,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ScaleAdd(targetObject, tweenParams); + iTween.ScaleAdd(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs index d680d58c..1bc4eadb 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs @@ -33,7 +33,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ScaleFrom(targetObject, tweenParams); + iTween.ScaleFrom(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs index af81d1e5..66978992 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs @@ -33,7 +33,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ScaleTo(targetObject, tweenParams); + iTween.ScaleTo(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs index 8da68a2a..e615e957 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs @@ -42,7 +42,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ShakePosition(targetObject, tweenParams); + iTween.ShakePosition(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs index 8950d64e..679a942a 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs @@ -27,7 +27,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ShakeRotation(targetObject, tweenParams); + iTween.ShakeRotation(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs index d26ad140..ff0d1b46 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs @@ -23,7 +23,7 @@ namespace Fungus tweenParams.Add("oncomplete", "OniTweenComplete"); tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); - iTween.ShakeScale(targetObject, tweenParams); + iTween.ShakeScale(_targetObject.Value, tweenParams); } } diff --git a/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs index 25d715f2..04a11a9a 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs @@ -4,6 +4,7 @@ using UnityEngine.Serialization; namespace Fungus { + public enum iTweenAxis { None, @@ -12,12 +13,16 @@ namespace Fungus Z } - public abstract class iTweenCommand : Command + public abstract class iTweenCommand : Command, IUpdateable { - [Tooltip("Target game object to apply the Tween to")] + // Obsolete: Use _targetObject instead. + [HideInInspector] [FormerlySerializedAs("target")] public GameObject targetObject; + [Tooltip("Target game object to apply the Tween to")] + public GameObjectData _targetObject; + [Tooltip("An individual name useful for stopping iTweens by name")] public string tweenName; @@ -38,7 +43,7 @@ namespace Fungus public override void OnEnter() { - if (targetObject == null) + if (_targetObject.Value == null) { Continue(); return; @@ -47,7 +52,7 @@ namespace Fungus if (stopPreviousTweens) { // Force any existing iTweens on this target object to complete immediately - iTween[] tweens = targetObject.GetComponents(); + iTween[] tweens = _targetObject.Value.GetComponents(); foreach (iTween tween in tweens) { tween.time = 0; tween.SendMessage("Update"); @@ -79,18 +84,33 @@ namespace Fungus public override string GetSummary() { - if (targetObject == null) + if (_targetObject.Value == null) { return "Error: No target object selected"; } - return targetObject.name + " over " + duration + " seconds"; + return _targetObject.Value.name + " over " + duration + " seconds"; } public override Color GetButtonColor() { return new Color32(233, 163, 180, 255); } + + // + // IUpdateable implementation + // + + public virtual void UpdateToVersion(int oldVersion, int newVersion) + { + if (oldVersion == 0 && + targetObject != null) + { + _targetObject.gameObjectVal = targetObject; + _targetObject.gameObjectRef = null; + targetObject = null; + } + } } } \ No newline at end of file