string ParseVariable(string varName) { //Check YarnSpinner's variable storage first if (variableStorage.GetValue(varName) != Yarn.Value.NULL) { return(variableStorage.GetValue(varName).AsString); } //Handle other variables here if (varName == "$time") { return(Time.time.ToString()); } //If no variables are found, return the variable name return(varName); }
public string SubstituteVariables(string text) { int searchIndex = 0; while (true) { int openIndex = text.IndexOf("{", searchIndex); int closeIndex = text.IndexOf("}", searchIndex); if (openIndex < 0 || closeIndex < openIndex) { return(text); } string variableName = text.Substring(openIndex + 1, closeIndex - openIndex - 1); string variableValue = variableStorage.GetValue(variableName).AsString; text = text.Substring(0, openIndex) + variableValue + text.Substring(closeIndex + 1); searchIndex = openIndex + variableValue.Length; } }
public void Load(string fileName = "main") { variableStorage.GetValue("SaveFile" + fileName); }