diff --git a/Assets/Fungus/Narrative/Editor/MenuTimerEditor.cs b/Assets/Fungus/Narrative/Editor/MenuTimerEditor.cs index 4c94911f..666c55aa 100644 --- a/Assets/Fungus/Narrative/Editor/MenuTimerEditor.cs +++ b/Assets/Fungus/Narrative/Editor/MenuTimerEditor.cs @@ -17,7 +17,7 @@ namespace Fungus if (NullTargetCheck()) // Check for an orphaned editor instance return; - durationProp = serializedObject.FindProperty("duration"); + durationProp = serializedObject.FindProperty("_duration"); targetBlockProp = serializedObject.FindProperty("targetBlock"); } diff --git a/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs index dbee1b84..09066563 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs +++ b/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs @@ -11,10 +11,14 @@ namespace Fungus "Menu Timer", "Displays a timer bar and executes a target block if the player fails to select a menu option in time.")] [AddComponentMenu("")] - public class MenuTimer : Command + public class MenuTimer : Command, ISerializationCallbackReceiver { + #region Obsolete Properties + [HideInInspector] [FormerlySerializedAs("duration")] public float durationOLD; + #endregion + [Tooltip("Length of time to display the timer for")] - public float duration; + public FloatData _duration = new FloatData(1); [FormerlySerializedAs("targetSequence")] [Tooltip("Block to execute when the timer expires")] @@ -27,7 +31,7 @@ namespace Fungus if (menuDialog != null && targetBlock != null) { - menuDialog.ShowTimer(duration, targetBlock); + menuDialog.ShowTimer(_duration.Value, targetBlock); } Continue(); @@ -55,6 +59,22 @@ namespace Fungus { return new Color32(184, 210, 235, 255); } + + // + // ISerializationCallbackReceiver implementation + // + + public virtual void OnBeforeSerialize() + {} + + public virtual void OnAfterDeserialize() + { + if (durationOLD != default(float)) + { + _duration.Value = durationOLD; + durationOLD = default(float); + } + } } } \ No newline at end of file diff --git a/Assets/UpdatePropTest.unity b/Assets/UpdatePropTest.unity index ab3c9b74..e18423d2 100644 --- a/Assets/UpdatePropTest.unity +++ b/Assets/UpdatePropTest.unity @@ -311,6 +311,7 @@ GameObject: - 114: {fileID: 979963253} - 114: {fileID: 979963256} - 114: {fileID: 979963257} + - 114: {fileID: 979963258} m_Layer: 0 m_Name: Flowchart m_TagString: Untagged @@ -344,7 +345,7 @@ MonoBehaviour: height: 859 selectedBlock: {fileID: 979963241} selectedCommands: - - {fileID: 979963257} + - {fileID: 979963258} variables: - {fileID: 979963244} - {fileID: 979963252} @@ -416,6 +417,7 @@ MonoBehaviour: - {fileID: 979963253} - {fileID: 979963256} - {fileID: 979963257} + - {fileID: 979963258} --- !u!114 &979963242 MonoBehaviour: m_ObjectHideFlags: 2 @@ -721,7 +723,26 @@ MonoBehaviour: itemId: 13 errorMessage: indentLevel: 0 - duration: 5 + durationOLD: 0 + _duration: + floatRef: {fileID: 0} + floatVal: 5 +--- !u!114 &979963258 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 979963238} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab54728d981544842843ba6609b9a80a, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 14 + errorMessage: + indentLevel: 0 + duration: 6 + targetBlock: {fileID: 979963241} --- !u!1 &1197120973 GameObject: m_ObjectHideFlags: 0