From b61a9180757b3a417aeab985226ad915b2ad90d1 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Tue, 19 Dec 2017 20:54:48 +1000 Subject: [PATCH] Fix bug found by @FatPuzo by force returning local value on global variables when their value is requested outside of play mode --- Assets/Fungus/Scripts/Components/Variable.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Scripts/Components/Variable.cs b/Assets/Fungus/Scripts/Components/Variable.cs index 8c7ddb75..4fb7ea3d 100644 --- a/Assets/Fungus/Scripts/Components/Variable.cs +++ b/Assets/Fungus/Scripts/Components/Variable.cs @@ -121,10 +121,14 @@ namespace Fungus { return _globalStaicRef; } - else + else if(Application.isPlaying) { return _globalStaicRef = FungusManager.Instance.GlobalVariables.GetOrAddVariable(Key, value, this.GetType()); } + else + { + return null; + } } } @@ -133,7 +137,7 @@ namespace Fungus { get { - if (scope != VariableScope.Global) + if (scope != VariableScope.Global || !Application.isPlaying) { return this.value; } @@ -144,7 +148,7 @@ namespace Fungus } set { - if (scope != VariableScope.Global) + if (scope != VariableScope.Global || !Application.isPlaying) { this.value = value; }