コード例 #1
0
        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);
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public void Load(string fileName = "main")
 {
     variableStorage.GetValue("SaveFile" + fileName);
 }