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