Browse Source

MenuTimer can now use a variable

master
chrisgregan 9 years ago
parent
commit
42c77d899b
  1. 2
      Assets/Fungus/Narrative/Editor/MenuTimerEditor.cs
  2. 26
      Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs
  3. 25
      Assets/UpdatePropTest.unity

2
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");
}

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

25
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

Loading…
Cancel
Save