I was wondering if this was good design from client side calls. In the event that the key doesn't exist, go ahead and add it.
public static void SetVariable(string name, object value)
{
if (variables == null)
{
variables = new Dictionary<string, object>();
}
if(variables.ContainsKey(name))
{
variables[name] = value;
}
else
{
Debug.LogError("Added Unknown Data to Global Data");
variables.Add(name,value);
}
//EmberDebug.Log( name + " = "+ value );
}
Dictionary
, that would work too. – svick May 4 '13 at 12:32Set
function is good, and that variables should be initialized before (preferably in the constructor). What do you think will happen if you try toGet
and your dictionary is null? – Max Dec 20 '13 at 7:58