Hi,
I have a scene where I create gameobjects from a prefab in the Resources folder at runtime:
var runtimeObject =(GameObject)UnityEngine.GameObject.Instantiate(Resources.Load(actorsTemplate_[rr]));
These object have a dictionary member called private
private Dictionary<string, float> floatUpdate;
At runtime, I add some stuff to the dictionaries in this way:
public void SetFloatParameter(string Name, float value)
{
if (floatUpdate.ContainsKey("Name"))
floatUpdate[Name] = value; // !!LINE #1
else
floatUpdate.Add(Name, value); // !!LINE #2
}
The problem I’m facing is:
ArgumentException: An element with the same key already exists in the dictionary.
on the !!LINE #1 (as specified in the code block after // comment).
What could be causing this?
Thanks.