From 45cc8416ec2bec41db36597d711ae752c9924544 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 13 Oct 2016 14:13:47 +0100 Subject: [PATCH] Added WaitFrames command --- Assets/Fungus/Scripts/Commands/WaitFrames.cs | 54 +++++++++++++++++++ .../Scripts/Commands/WaitFrames.cs.meta | 8 +++ 2 files changed, 62 insertions(+) create mode 100644 Assets/Fungus/Scripts/Commands/WaitFrames.cs create mode 100644 Assets/Fungus/Scripts/Commands/WaitFrames.cs.meta diff --git a/Assets/Fungus/Scripts/Commands/WaitFrames.cs b/Assets/Fungus/Scripts/Commands/WaitFrames.cs new file mode 100644 index 00000000..3fc0054b --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/WaitFrames.cs @@ -0,0 +1,54 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +using UnityEngine; +using UnityEngine.Serialization; +using System.Collections; + +namespace Fungus +{ + /// + /// Waits for a number of frames before executing the next command in the block. + /// + [CommandInfo("Flow", + "WaitFrames", + "Waits for a number of frames before executing the next command in the block.")] + [AddComponentMenu("")] + [ExecuteInEditMode] + public class WaitFrames : Command + { + [Tooltip("Number of frames to wait for")] + [SerializeField] protected IntegerData frameCount = new IntegerData(1); + + protected virtual IEnumerator WaitForFrames() + { + int count = frameCount.Value; + while (count > 0) + { + yield return new WaitForEndOfFrame(); + count--; + } + + Continue(); + } + + #region Public members + + public override void OnEnter() + { + StartCoroutine(WaitForFrames()); + } + + public override string GetSummary() + { + return frameCount.Value.ToString() + " frames"; + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/WaitFrames.cs.meta b/Assets/Fungus/Scripts/Commands/WaitFrames.cs.meta new file mode 100644 index 00000000..fdfd318a --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/WaitFrames.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de9232e9295ed476a8cfb707b5c242b9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: