From d81c45f8f19377526240a19c5a745c3a81ef4296 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 13 Apr 2015 21:18:37 +0100 Subject: [PATCH] Executing command icon fades out over time Makes it easier to visualize executing commands --- Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs | 9 ++++++++- Assets/Fungus/Flowchart/Scripts/Block.cs | 6 +++++- Assets/Fungus/Flowchart/Scripts/Command.cs | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs index dad9a176..7b8eda2e 100644 --- a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs @@ -362,13 +362,20 @@ namespace Fungus GUI.Label(commandLabelRect, commandName, commandLabelStyle); } - if (command.isExecuting) + if (command.executingIconTimer > 0f) { Rect iconRect = new Rect(commandLabelRect); iconRect.x += iconRect.width - commandLabelRect.width - 20; iconRect.width = 20; iconRect.height = 20; + + Color storeColor = GUI.color; + + GUI.color = new Color(1f, 1f, 1f, command.executingIconTimer / Block.executingIconFadeTime); + command.executingIconTimer = Mathf.Max(0, command.executingIconTimer - Time.deltaTime); GUI.Label(iconRect, FungusEditorResources.texPlaySmall, new GUIStyle()); + + GUI.color = storeColor; } Rect summaryRect = new Rect(commandLabelRect); diff --git a/Assets/Fungus/Flowchart/Scripts/Block.cs b/Assets/Fungus/Flowchart/Scripts/Block.cs index 03cb3feb..71ad8261 100644 --- a/Assets/Fungus/Flowchart/Scripts/Block.cs +++ b/Assets/Fungus/Flowchart/Scripts/Block.cs @@ -64,6 +64,8 @@ namespace Fungus protected int executionCount; + public const float executingIconFadeTime = 0.5f; + /** * Controls the next command to execute in the block execution coroutine. */ @@ -210,7 +212,7 @@ namespace Fungus Command command = commandList[i]; activeCommand = command; - executingIconTimer = 0.5f; + executingIconTimer = executingIconFadeTime; if (flowchart.gameObject.activeInHierarchy) { @@ -224,11 +226,13 @@ namespace Fungus } command.isExecuting = true; + command.executingIconTimer = executingIconFadeTime; command.Execute(); // Wait until the executing command sets another command to jump to via Command.Continue() while (jumpToCommandIndex == -1) { + command.executingIconTimer = executingIconFadeTime; yield return null; } diff --git a/Assets/Fungus/Flowchart/Scripts/Command.cs b/Assets/Fungus/Flowchart/Scripts/Command.cs index c53680d4..78216bf5 100644 --- a/Assets/Fungus/Flowchart/Scripts/Command.cs +++ b/Assets/Fungus/Flowchart/Scripts/Command.cs @@ -51,6 +51,12 @@ namespace Fungus [NonSerialized] public bool isExecuting; + /** + * Timer used to control appearance of executing icon in inspector. + */ + [NonSerialized] + public float executingIconTimer; + /** * Reference to the Block object that this command belongs to. * This reference is only populated at runtime and in the editor when the