From b22ae7de6d918c4a2dbf966763f632fbd126ca84 Mon Sep 17 00:00:00 2001 From: CG-Tespy Date: Wed, 16 Sep 2020 07:03:57 -0400 Subject: [PATCH] Fixed issue with variables being modified when the key isn't valid --- Assets/Fungus/Scripts/Commands/LoadVariable.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs index 06380227..29b2e19f 100644 --- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs @@ -28,18 +28,19 @@ namespace Fungus public override void OnEnter() { - if (key == "" || - variable == null) + var flowchart = GetFlowchart(); + + // Prepend the current save profile (if any) and make sure all inputs are valid + string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key); + bool validKey = key != "" && PlayerPrefs.HasKey(prefsKey); + bool validVariable = variable != null; + + if (!validKey || !validVariable) { Continue(); return; } - var flowchart = GetFlowchart(); - - // Prepend the current save profile (if any) - string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key); - System.Type variableType = variable.GetType(); if (variableType == typeof(BooleanVariable))