/// <summary> /// Adds an object to the custom config vars if and only if it does not already exist (function version) /// </summary> public void AddCustomVarIfNotExists <T>(string name, Func <T> customVarBuilder) { if (CustomConfigVars.ContainsKey(name)) { if (CustomConfigVars[name] == null || CustomConfigVars[name].GetType() != typeof(T)) { Debug.LogWarning($"[Config] Custom config var {name} exists but contains a {CustomConfigVars[name]?.GetType()?.Name} instead of a {typeof(T).Name}"); } } else { CustomConfigVars.Add(name, customVarBuilder()); } }
/// <summary> /// Adds an object to the custom config vars if and only if it does not already exist /// </summary> public void AddCustomVarIfNotExists(string name, object customVar) { if (CustomConfigVars.ContainsKey(name)) { if (CustomConfigVars[name] == null || CustomConfigVars[name].GetType() != customVar.GetType()) { Debug.LogWarning($"[Config] Custom config var {name} exists but contains a {CustomConfigVars[name]?.GetType()?.Name} instead of a {customVar.GetType().Name}"); } } else { CustomConfigVars.Add(name, customVar); } }