Browse Source

Executing command icon fades out over time

Makes it easier to visualize executing commands
master
chrisgregan 10 years ago
parent
commit
d81c45f8f1
  1. 9
      Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs
  2. 6
      Assets/Fungus/Flowchart/Scripts/Block.cs
  3. 6
      Assets/Fungus/Flowchart/Scripts/Command.cs

9
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);

6
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;
}

6
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

Loading…
Cancel
Save