From 495e596868abadb1056c8e44bb047d38944f5c35 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 22 Jan 2016 12:43:28 +0000 Subject: [PATCH] Fixed ensure parentBlock is set when block executes #320 --- Assets/Fungus/Flowchart/Scripts/Block.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/Fungus/Flowchart/Scripts/Block.cs b/Assets/Fungus/Flowchart/Scripts/Block.cs index 946d7398..2b31ecb9 100644 --- a/Assets/Fungus/Flowchart/Scripts/Block.cs +++ b/Assets/Fungus/Flowchart/Scripts/Block.cs @@ -64,7 +64,14 @@ namespace Fungus [NonSerialized] public int jumpToCommandIndex = -1; + protected bool executionInfoSet = false; + protected virtual void Awake() + { + SetExecutionInfo(); + } + + protected virtual void SetExecutionInfo() { // Give each child command a reference back to its parent block // and tell each command its index in the list. @@ -79,6 +86,8 @@ namespace Fungus command.parentBlock = this; command.commandIndex = index++; } + + executionInfoSet = true; } #if UNITY_EDITOR @@ -135,6 +144,11 @@ namespace Fungus return false; } + if (!executionInfoSet) + { + SetExecutionInfo(); + } + executionCount++; StartCoroutine(ExecuteBlock(onComplete));