-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Godot and C# (system) Dictionary class #25825
Comments
Dictionary and Array expect objects that can be marshalled as Variant (which includes classes that inherit from From what I understand, you expect My recommendation is, only use the collections in Right now, only |
Yes, exactly. Now
I don't think it has to have knowledge of an object being a managed object. Shouldn’t be enough if engine supported on general object (Variant? I mean the class type from GDScript which managed objects take form of)
Well, I wanted to have only computationally demanding tasks in C# (or C++) and sharing results to GDScript where I could do everything else. But a dictionary which cannot properly test equality is a problem (I really don't want to manage a pool of all possible keys, which will heavily change over time, since I believe it would be quite bad for performance [it will be used in many tight loops]). I think converting between dictionaries (Mono and Godot one) will be quite costly. And another issue is |
Variant's |
Would it be enough for |
The If I am the only one asking about this, I am not sure adding a special case (bringing inconsistency) is worth it. The option of overriding equality checking for objects would be great, but I don't know anything about engine's internals, so if you say the cost is probably too high compared to what it brings, I wouldn't pursue this path. Thank you for your time 🙂. |
Godot version:
3.1.beta3.mono.official
OS/device including version:
Linux 64b, Kubuntu 16.04
Issue description:
System.Collections.Generic.Dictionary
andGodot.Collections.Dictionary
are not behaving same when it comes to key comparison.Is it possible to have a custom class as a key in a Godot Dictionary? At first I wanted to use struct, but Godot Dictionary kept refusing it, so I changed it to a class and it seemed to be working. Until I created a new key with values of one existing key in the dictionary and tried to get data from the dictionary. Is this a limitation, bug or intention? Is it even possible to fix (I really have no idea how data are passed between engine and C# part)?
By the way, the custom key is Vector3Int. I still can't comprehend why Godot is missing such a basic thing (for years?).
Steps to reproduce:
Attach the above script to a node in a project and run.
The text was updated successfully, but these errors were encountered: