Browse Source

Fixed ensure parentBlock is set when block executes #320

master
chrisgregan 9 years ago
parent
commit
495e596868
  1. 14
      Assets/Fungus/Flowchart/Scripts/Block.cs

14
Assets/Fungus/Flowchart/Scripts/Block.cs

@ -64,7 +64,14 @@ namespace Fungus
[NonSerialized] [NonSerialized]
public int jumpToCommandIndex = -1; public int jumpToCommandIndex = -1;
protected bool executionInfoSet = false;
protected virtual void Awake() protected virtual void Awake()
{
SetExecutionInfo();
}
protected virtual void SetExecutionInfo()
{ {
// Give each child command a reference back to its parent block // Give each child command a reference back to its parent block
// and tell each command its index in the list. // and tell each command its index in the list.
@ -79,6 +86,8 @@ namespace Fungus
command.parentBlock = this; command.parentBlock = this;
command.commandIndex = index++; command.commandIndex = index++;
} }
executionInfoSet = true;
} }
#if UNITY_EDITOR #if UNITY_EDITOR
@ -135,6 +144,11 @@ namespace Fungus
return false; return false;
} }
if (!executionInfoSet)
{
SetExecutionInfo();
}
executionCount++; executionCount++;
StartCoroutine(ExecuteBlock(onComplete)); StartCoroutine(ExecuteBlock(onComplete));

Loading…
Cancel
Save