Topic was automatically imported from the old Question2Answer platform.
Asked By
Supatier
Hi
Im trying to add a settings to the project with ProjectSettings.AddPropertyInfo() the input is Godot.Collections.Dictionary but i don’t know how to use it. I know how to create a dictionary in C# with new Dictionary<string, object>() but godot doesn’t accept it.
Such dictionary works like a C# dictionary, except keys and values are both object. It doesn’t implement IDictionary for some reason, maybe it will in the future.
var d = new Godot.Collections.Dictionary();
d.Add("name", "property_name");
// In GDScript it's TYPE_*, I believe GodotSharp has it in Variant.Type.*
d.Add("type", Variant.Type.String);
//...
And these are the expected keys and values:
Tbh it would be nice if a struct could be accepted there, because this function expects a specific set of keys and values and in C# it forces you to build this quite unexpected dictionary. I guess it’s a dict because it’s less work to bind and was easier so far to write in GDScript…
It worked. Thanks
Supatier | 2019-12-12 00:20
Unfortunately, this gives me the following error in Godot 4 beta1:
Argument type 'Godot.Variant.Type' is not assignable to parameter type 'Godot.Variant'