Browse Source

Merge pull request #872 from CG-Tespy/LoadVariableFix

Fixed issue with variables being modified when the key isn't valid
master
Steve Halliwell 4 years ago committed by GitHub
parent
commit
0c875222f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      Assets/Fungus/Scripts/Commands/LoadVariable.cs

15
Assets/Fungus/Scripts/Commands/LoadVariable.cs

@ -28,18 +28,19 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
if (key == "" || var flowchart = GetFlowchart();
variable == null)
// 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(); Continue();
return; return;
} }
var flowchart = GetFlowchart();
// Prepend the current save profile (if any)
string prefsKey = SetSaveProfile.SaveProfile + "_" + flowchart.SubstituteVariables(key);
System.Type variableType = variable.GetType(); System.Type variableType = variable.GetType();
if (variableType == typeof(BooleanVariable)) if (variableType == typeof(BooleanVariable))

Loading…
Cancel
Save