diff --git a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs index c0f324f0..bf0f8e0e 100644 --- a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs @@ -323,4 +323,8 @@ namespace Fungus [CustomPropertyDrawer (typeof(AnimatorData))] public class AnimatorDataDrawer : VariableDataDrawer {} + + [CustomPropertyDrawer (typeof(TransformData))] + public class TransformDataDrawer : VariableDataDrawer + {} } \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs new file mode 100644 index 00000000..5a541c50 --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs @@ -0,0 +1,51 @@ +using UnityEngine; +using System.Collections; + +namespace Fungus +{ + [VariableInfo("Other", "Transform")] + [AddComponentMenu("")] + public class TransformVariable : VariableBase + {} + + [System.Serializable] + public struct TransformData + { + [SerializeField] + [VariableProperty("", typeof(TransformVariable))] + public TransformVariable transformRef; + + [SerializeField] + public Transform transformVal; + + public TransformData(Transform v) + { + transformVal = v; + transformRef = null; + } + + public static implicit operator Transform(TransformData vector3Data) + { + return vector3Data.Value; + } + + public Transform Value + { + get { return (transformRef == null) ? transformVal : transformRef.value; } + set { if (transformRef == null) { transformVal = value; } else { transformRef.value = value; } } + } + + public string GetDescription() + { + if (transformRef == null) + { + return transformVal.ToString(); + } + else + { + return transformRef.key; + } + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs.meta b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs.meta new file mode 100644 index 00000000..d17780de --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 633bea14077b44e19956e8113fbac7a4 +timeCreated: 1457893486 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs index 02378b59..6e570a18 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Look From", "Instantly rotates a GameObject to look at the supplied Vector3 then returns it to it's starting rotation over time.")] [AddComponentMenu("")] - public class LookFrom : iTweenCommand + public class LookFrom : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; + [HideInInspector] [FormerlySerializedAs("fromPosition")] public Vector3 fromPositionOLD; + #endregion + [Tooltip("Target transform that the GameObject will look at")] - public Transform fromTransform; + public TransformData _fromTransform; [Tooltip("Target world position that the GameObject will look at, if no From Transform is set")] - public Vector3 fromPosition; + public Vector3Data _fromPosition; [Tooltip("Restricts rotation to the supplied axis only")] public iTweenAxis axis; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (fromTransform == null) + if (_fromTransform.Value == null) { - tweenParams.Add("looktarget", fromPosition); + tweenParams.Add("looktarget", _fromPosition.Value); } else { - tweenParams.Add("looktarget", fromTransform); + tweenParams.Add("looktarget", _fromTransform.Value); } switch (axis) { @@ -49,7 +55,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.LookFrom(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (fromTransformOLD != null) + { + _fromTransform.Value = fromTransformOLD; + fromTransformOLD = null; + } + + if (fromPositionOLD != default(Vector3)) + { + _fromPosition.Value = fromPositionOLD; + fromPositionOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs b/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs index a94ff629..bc7a035f 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/LookTo.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Look To", "Rotates a GameObject to look at a supplied Transform or Vector3 over time.")] [AddComponentMenu("")] - public class LookTo : iTweenCommand + public class LookTo : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; + [HideInInspector] [FormerlySerializedAs("toPosition")] public Vector3 toPositionOLD; + #endregion + [Tooltip("Target transform that the GameObject will look at")] - public Transform toTransform; + public TransformData _toTransform; [Tooltip("Target world position that the GameObject will look at, if no From Transform is set")] - public Vector3 toPosition; + public Vector3Data _toPosition; [Tooltip("Restricts rotation to the supplied axis only")] public iTweenAxis axis; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (toTransform == null) + if (_toTransform.Value == null) { - tweenParams.Add("looktarget", toPosition); + tweenParams.Add("looktarget", _toPosition.Value); } else { - tweenParams.Add("looktarget", toTransform); + tweenParams.Add("looktarget", _toTransform.Value); } switch (axis) { @@ -49,7 +55,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.LookTo(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (toTransformOLD != null) + { + _toTransform.Value = toTransformOLD; + toTransformOLD = null; + } + + if (toPositionOLD != default(Vector3)) + { + _toPosition.Value = toPositionOLD; + toPositionOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs index 5555db41..1d3a6a4f 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Move Add", "Moves a game object by a specified offset over time.")] [AddComponentMenu("")] - public class MoveAdd : iTweenCommand + public class MoveAdd : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; + #endregion + [Tooltip("A translation offset in space the GameObject will animate to")] - public Vector3 offset; + public Vector3Data _offset; [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] public Space space = Space.Self; @@ -19,7 +24,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", offset); + tweenParams.Add("amount", _offset.Value); tweenParams.Add("space", space); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -29,6 +34,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.MoveAdd(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (offsetOLD != default(Vector3)) + { + _offset.Value = offsetOLD; + offsetOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs index c8383e51..027646c5 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Move From", "Moves a game object from a specified position back to its starting position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None).")] [AddComponentMenu("")] - public class MoveFrom : iTweenCommand + public class MoveFrom : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; + [HideInInspector] [FormerlySerializedAs("fromPosition")] public Vector3 fromPositionOLD; + #endregion + [Tooltip("Target transform that the GameObject will move from")] - public Transform fromTransform; + public TransformData _fromTransform; [Tooltip("Target world position that the GameObject will move from, if no From Transform is set")] - public Vector3 fromPosition; + public Vector3Data _fromPosition; [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] public bool isLocal; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (fromTransform == null) + if (_fromTransform.Value == null) { - tweenParams.Add("position", fromPosition); + tweenParams.Add("position", _fromPosition.Value); } else { - tweenParams.Add("position", fromTransform); + tweenParams.Add("position", _fromTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -38,7 +44,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.MoveFrom(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (fromTransformOLD != null) + { + _fromTransform.Value = fromTransformOLD; + fromTransformOLD = null; + } + + if (fromPositionOLD != default(Vector3)) + { + _fromPosition.Value = fromPositionOLD; + fromPositionOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs b/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs index 854f2473..b8163caa 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Move To", "Moves a game object to a specified position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None).")] [AddComponentMenu("")] - public class MoveTo : iTweenCommand + public class MoveTo : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; + [HideInInspector] [FormerlySerializedAs("toPosition")] public Vector3 toPositionOLD; + #endregion + [Tooltip("Target transform that the GameObject will move to")] - public Transform toTransform; + public TransformData _toTransform; [Tooltip("Target world position that the GameObject will move to, if no From Transform is set")] - public Vector3 toPosition; + public Vector3Data _toPosition; [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] public bool isLocal; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (toTransform == null) + if (_toTransform.Value == null) { - tweenParams.Add("position", toPosition); + tweenParams.Add("position", _toPosition.Value); } else { - tweenParams.Add("position", toTransform); + tweenParams.Add("position", _toTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -38,7 +44,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.MoveTo(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (toTransformOLD != null) + { + _toTransform.Value = toTransformOLD; + toTransformOLD = null; + } + + if (toPositionOLD != default(Vector3)) + { + _toPosition.Value = toPositionOLD; + toPositionOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs index 42314d76..3b16d4dd 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Punch Position", "Applies a jolt of force to a GameObject's position and wobbles it back to its initial position.")] [AddComponentMenu("")] - public class PunchPosition : iTweenCommand + public class PunchPosition : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A translation offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] public Space space = Space.Self; @@ -19,7 +24,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); tweenParams.Add("space", space); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -29,6 +34,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.PunchPosition(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs index faa82159..7dc61581 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Punch Rotation", "Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation.")] [AddComponentMenu("")] - public class PunchRotation : iTweenCommand + public class PunchRotation : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A rotation offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] public Space space = Space.Self; @@ -19,7 +24,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); tweenParams.Add("space", space); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -29,6 +34,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.PunchRotation(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs b/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs index 365dbf98..f3e9002e 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,16 +8,20 @@ namespace Fungus "Punch Scale", "Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale.")] [AddComponentMenu("")] - public class PunchScale : iTweenCommand + public class PunchScale : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A scale offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; public override void DoTween() { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); tweenParams.Add("looptype", loopType); @@ -25,6 +30,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.PunchScale(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs index 362fd8de..ab18e756 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Rotate Add", "Rotates a game object by the specified angles over time.")] [AddComponentMenu("")] - public class RotateAdd : iTweenCommand + public class RotateAdd : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; + #endregion + [Tooltip("A rotation offset in space the GameObject will animate to")] - public Vector3 offset; + public Vector3Data _offset; [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] public Space space = Space.Self; @@ -19,7 +24,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", offset); + tweenParams.Add("amount", _offset.Value); tweenParams.Add("space", space); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -29,6 +34,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.RotateAdd(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (offsetOLD != default(Vector3)) + { + _offset.Value = offsetOLD; + offsetOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs index 8004f018..4b4561e3 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Rotate From", "Rotates a game object from the specified angles back to its starting orientation over time.")] [AddComponentMenu("")] - public class RotateFrom : iTweenCommand + public class RotateFrom : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; + [HideInInspector] [FormerlySerializedAs("fromRotation")] public Vector3 fromRotationOLD; + #endregion + [Tooltip("Target transform that the GameObject will rotate from")] - public Transform fromTransform; + public TransformData _fromTransform; [Tooltip("Target rotation that the GameObject will rotate from, if no From Transform is set")] - public Vector3 fromRotation; + public Vector3Data _fromRotation; [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] public bool isLocal; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (fromTransform == null) + if (_fromTransform.Value == null) { - tweenParams.Add("rotation", fromRotation); + tweenParams.Add("rotation", _fromRotation.Value); } else { - tweenParams.Add("rotation", fromTransform); + tweenParams.Add("rotation", _fromTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -38,7 +44,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.RotateFrom(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (fromTransformOLD != null) + { + _fromTransform.Value = fromTransformOLD; + fromTransformOLD = null; + } + + if (fromRotationOLD != default(Vector3)) + { + _fromRotation.Value = fromRotationOLD; + fromRotationOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs b/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs index 2853d289..8b91b402 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,13 +8,18 @@ namespace Fungus "Rotate To", "Rotates a game object to the specified angles over time.")] [AddComponentMenu("")] - public class RotateTo : iTweenCommand + public class RotateTo : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; + [HideInInspector] [FormerlySerializedAs("toRotation")] public Vector3 toRotationOLD; + #endregion + [Tooltip("Target transform that the GameObject will rotate to")] - public Transform toTransform; + public TransformData _toTransform; [Tooltip("Target rotation that the GameObject will rotate to, if no To Transform is set")] - public Vector3 toRotation; + public Vector3Data _toRotation; [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] public bool isLocal; @@ -22,13 +28,13 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (toTransform == null) + if (_toTransform.Value == null) { - tweenParams.Add("rotation", toRotation); + tweenParams.Add("rotation", _toRotation.Value); } else { - tweenParams.Add("rotation", toTransform); + tweenParams.Add("rotation", _toTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -38,7 +44,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.RotateTo(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (toTransformOLD != null) + { + _toTransform.Value = toTransformOLD; + toTransformOLD = null; + } + + if (toRotationOLD != default(Vector3)) + { + _toRotation.Value = toRotationOLD; + toRotationOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs index 9be89ac9..5be57f33 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,16 +8,20 @@ namespace Fungus "Scale Add", "Changes a game object's scale by a specified offset over time.")] [AddComponentMenu("")] - public class ScaleAdd : iTweenCommand + public class ScaleAdd : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; + #endregion + [Tooltip("A scale offset in space the GameObject will animate to")] - public Vector3 offset; + public Vector3Data _offset; public override void DoTween() { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", offset); + tweenParams.Add("amount", _offset.Value); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); tweenParams.Add("looptype", loopType); @@ -25,6 +30,22 @@ namespace Fungus tweenParams.Add("oncompleteparams", this); iTween.ScaleAdd(_targetObject.Value, tweenParams); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (offsetOLD != default(Vector3)) + { + _offset.Value = offsetOLD; + offsetOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs index 54741150..d167364f 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,25 +8,30 @@ namespace Fungus "Scale From", "Changes a game object's scale to the specified value and back to its original scale over time.")] [AddComponentMenu("")] - public class ScaleFrom : iTweenCommand + public class ScaleFrom : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; + [HideInInspector] [FormerlySerializedAs("fromScale")] public Vector3 fromScaleOLD; + #endregion + [Tooltip("Target transform that the GameObject will scale from")] - public Transform fromTransform; + public TransformData _fromTransform; [Tooltip("Target scale that the GameObject will scale from, if no From Transform is set")] - public Vector3 fromScale; + public Vector3Data _fromScale; public override void DoTween() { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (fromTransform == null) + if (_fromTransform.Value == null) { - tweenParams.Add("scale", fromScale); + tweenParams.Add("scale", _fromScale.Value); } else { - tweenParams.Add("scale", fromTransform); + tweenParams.Add("scale", _fromTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -34,7 +40,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.ScaleFrom(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (fromTransformOLD != null) + { + _fromTransform.Value = fromTransformOLD; + fromTransformOLD = null; + } + + if (fromScaleOLD != default(Vector3)) + { + _fromScale.Value = fromScaleOLD; + fromScaleOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs index 21b6f183..f33de0a2 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,25 +8,30 @@ namespace Fungus "Scale To", "Changes a game object's scale to a specified value over time.")] [AddComponentMenu("")] - public class ScaleTo : iTweenCommand + public class ScaleTo : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; + [HideInInspector] [FormerlySerializedAs("toScale")] public Vector3 toScaleOLD; + #endregion + [Tooltip("Target transform that the GameObject will scale to")] - public Transform toTransform; + public TransformData _toTransform; [Tooltip("Target scale that the GameObject will scale to, if no To Transform is set")] - public Vector3 toScale = new Vector3(1f, 1f, 1f); + public Vector3Data _toScale = new Vector3Data(Vector3.one); public override void DoTween() { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - if (toTransform == null) + if (_toTransform.Value == null) { - tweenParams.Add("scale", toScale); + tweenParams.Add("scale", _toScale.Value); } else { - tweenParams.Add("scale", toTransform); + tweenParams.Add("scale", _toTransform.Value); } tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -34,7 +40,29 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.ScaleTo(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (toTransformOLD != null) + { + _toTransform.Value = toTransformOLD; + toTransformOLD = null; + } + + if (toScaleOLD != default(Vector3)) + { + _toScale.Value = toScaleOLD; + toScaleOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs index ab2ebdad..e1f06af9 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Shake Position", "Randomly shakes a GameObject's position by a diminishing amount over time.")] [AddComponentMenu("")] - public class ShakePosition : iTweenCommand + public class ShakePosition : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A translation offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] public bool isLocal; @@ -22,7 +27,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); switch (axis) { case iTweenAxis.X: @@ -43,7 +48,23 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.ShakePosition(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs index 466c90df..59443e2e 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,10 +8,14 @@ namespace Fungus "Shake Rotation", "Randomly shakes a GameObject's rotation by a diminishing amount over time.")] [AddComponentMenu("")] - public class ShakeRotation : iTweenCommand + public class ShakeRotation : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A rotation offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] public Space space = Space.Self; @@ -19,7 +24,7 @@ namespace Fungus { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); tweenParams.Add("space", space); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); @@ -28,7 +33,23 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.ShakeRotation(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs index 8cd2f53f..92c9477d 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,16 +8,20 @@ namespace Fungus "Shake Scale", "Randomly shakes a GameObject's rotation by a diminishing amount over time.")] [AddComponentMenu("")] - public class ShakeScale : iTweenCommand + public class ShakeScale : iTweenCommand, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; + #endregion + [Tooltip("A scale offset in space the GameObject will animate to")] - public Vector3 amount; + public Vector3Data _amount; public override void DoTween() { Hashtable tweenParams = new Hashtable(); tweenParams.Add("name", _tweenName.Value); - tweenParams.Add("amount", amount); + tweenParams.Add("amount", _amount.Value); tweenParams.Add("time", duration); tweenParams.Add("easetype", easeType); tweenParams.Add("looptype", loopType); @@ -24,7 +29,23 @@ namespace Fungus tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.ShakeScale(_targetObject.Value, tweenParams); - } + } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (amountOLD != default(Vector3)) + { + _amount.Value = amountOLD; + amountOLD = default(Vector3); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/StopTween.cs b/Assets/Fungus/iTween/Scripts/Commands/StopTween.cs index c2622ed1..eeda68f2 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/StopTween.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/StopTween.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using System.Collections; namespace Fungus @@ -7,16 +8,36 @@ namespace Fungus "Stop Tween", "Stops an active iTween by name.")] [AddComponentMenu("")] - public class StopTween : Command + public class StopTween : Command, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("tweenName")] public string tweenNameOLD; + #endregion + [Tooltip("Stop and destroy any Tweens in current scene with the supplied name")] - public string tweenName; + public StringData _tweenName; public override void OnEnter() { - iTween.StopByName(tweenName); + iTween.StopByName(_tweenName.Value); Continue(); } + + // + // ISerializationCallbackReceiver implementation + // + + public void OnBeforeSerialize() + {} + + public void OnAfterDeserialize() + { + if (tweenNameOLD != "") + { + _tweenName.Value = tweenNameOLD; + tweenNameOLD = ""; + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/iTween/Scripts/Commands/StopTweens.cs b/Assets/Fungus/iTween/Scripts/Commands/StopTweens.cs index 362c2f88..3e323ca2 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/StopTweens.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/StopTweens.cs @@ -7,7 +7,7 @@ namespace Fungus "Stop Tweens", "Stop all active iTweens in the current scene.")] [AddComponentMenu("")] - public class StopTweens : Command + public class StopTweens : Command { public override void OnEnter() {