public static T GetValue <T>(int hash, T fallbackValue = default) { if (!VariablesModule.HasInstance()) { Initialize(); } var variables = Module.variables; if (variables.TryGetValue(hash, out var variable)) { return(variable.GetValue(fallbackValue)); } //Debug.Log($"Variable does not exist. Returning fallback value."); return(fallbackValue); }
public static T Get <T>(int hash, bool allowNull = false) where T : Variable { if (!VariablesModule.HasInstance()) { Initialize(); } var variables = Module.variables; if (variables.TryGetValue(hash, out var variable)) { return((T)variable); } if (!allowNull) { Debug.LogError($"Variable is not loaded."); //throw new KeyNotFoundException($"Variable with name {name} is not loaded."); } Debug.LogWarning($"Variable is not loaded, returning null"); return(null); }