diff --git a/Assets/_MAIN/Scripts/Core/Store.cs b/Assets/_MAIN/Scripts/Core/Store.cs index 64cc40b..2e94d47 100644 --- a/Assets/_MAIN/Scripts/Core/Store.cs +++ b/Assets/_MAIN/Scripts/Core/Store.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using UnityEngine; +using System.Text.RegularExpressions; public class Store { @@ -54,20 +55,17 @@ public class Store { Debug.LogWarning($"VariableManager :: Cannot add {valueStr} to {name} (Type: {current.GetType()})"); } - - Debug.Log($"VariableManager :: Add {name} += {valueStr} -> {_variables[name]}"); } - public string ReplaceVariables(string text) { if (string.IsNullOrEmpty(text) || !text.Contains("{")) return text; - foreach (var kvp in _variables) + return Regex.Replace(text, @"\{([^}]+)\}", match => { - text = text.Replace($"{{{kvp.Key}}}", kvp.Value.ToString()); - } - return text; + string key = match.Groups[1].Value; + return _variables.ContainsKey(key) ? _variables[key].ToString() : match.Value; + }); } } diff --git a/Assets/_MAIN/Scripts/Core/VNManager.cs b/Assets/_MAIN/Scripts/Core/VNManager.cs index 92ec3d6..da5c8fd 100644 --- a/Assets/_MAIN/Scripts/Core/VNManager.cs +++ b/Assets/_MAIN/Scripts/Core/VNManager.cs @@ -62,7 +62,6 @@ public class VNManager : MonoBehaviour NextStep(); } - void Update() { DisplayEffects(dialogueText);