Browse Source

iTween properties accept variables

master
chrisgregan 9 years ago
parent
commit
9788021f2c
  1. 4
      Assets/Fungus/Flowchart/Editor/VariableEditor.cs
  2. 51
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs
  3. 12
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs.meta
  4. 42
      Assets/Fungus/iTween/Scripts/Commands/LookFrom.cs
  5. 42
      Assets/Fungus/iTween/Scripts/Commands/LookTo.cs
  6. 27
      Assets/Fungus/iTween/Scripts/Commands/MoveAdd.cs
  7. 42
      Assets/Fungus/iTween/Scripts/Commands/MoveFrom.cs
  8. 42
      Assets/Fungus/iTween/Scripts/Commands/MoveTo.cs
  9. 27
      Assets/Fungus/iTween/Scripts/Commands/PunchPosition.cs
  10. 27
      Assets/Fungus/iTween/Scripts/Commands/PunchRotation.cs
  11. 27
      Assets/Fungus/iTween/Scripts/Commands/PunchScale.cs
  12. 27
      Assets/Fungus/iTween/Scripts/Commands/RotateAdd.cs
  13. 42
      Assets/Fungus/iTween/Scripts/Commands/RotateFrom.cs
  14. 42
      Assets/Fungus/iTween/Scripts/Commands/RotateTo.cs
  15. 27
      Assets/Fungus/iTween/Scripts/Commands/ScaleAdd.cs
  16. 42
      Assets/Fungus/iTween/Scripts/Commands/ScaleFrom.cs
  17. 42
      Assets/Fungus/iTween/Scripts/Commands/ScaleTo.cs
  18. 29
      Assets/Fungus/iTween/Scripts/Commands/ShakePosition.cs
  19. 29
      Assets/Fungus/iTween/Scripts/Commands/ShakeRotation.cs
  20. 29
      Assets/Fungus/iTween/Scripts/Commands/ShakeScale.cs
  21. 27
      Assets/Fungus/iTween/Scripts/Commands/StopTween.cs
  22. 2
      Assets/Fungus/iTween/Scripts/Commands/StopTweens.cs

4
Assets/Fungus/Flowchart/Editor/VariableEditor.cs

@ -323,4 +323,8 @@ namespace Fungus
[CustomPropertyDrawer (typeof(AnimatorData))]
public class AnimatorDataDrawer : VariableDataDrawer<AnimatorVariable>
{}
[CustomPropertyDrawer (typeof(TransformData))]
public class TransformDataDrawer : VariableDataDrawer<TransformVariable>
{}
}

51
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<Transform>
{}
[System.Serializable]
public struct TransformData
{
[SerializeField]
[VariableProperty("<Value>", 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;
}
}
}
}

12
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:

42
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);
}
}
}
}

42
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);
}
}
}
}

27
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);
}
}
}
}

42
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);
}
}
}
}

42
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);
}
}
}
}

27
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);
}
}
}
}

27
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);
}
}
}
}

27
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);
}
}
}
}

27
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);
}
}
}
}

42
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);
}
}
}
}

42
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);
}
}
}
}

27
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);
}
}
}
}

42
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);
}
}
}
}

42
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);
}
}
}
}

29
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);
}
}
}
}

29
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);
}
}
}
}

29
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);
}
}
}
}

27
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 = "";
}
}
}
}

2
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()
{

Loading…
Cancel
Save