-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
C#: Allow exporting custom types (System.Object class or struct) #997
Comments
Related to #438 |
Thx, but your addon is not related to the proposal. It just assumes that resources that godot can already export have scripts contained in predefined folders to register those to godot's property editor dropdown. This proposal is for exporting clr types like struct, that godot currently doesn't handle. |
This is a pretty huge pain point for me right now as I'd love to be able to group my exported fields through subclasses the same way I did in Unity. I'm trying to get debug visibility on more complicated fields that are mainly driven by runtime operations, and the only way I found to do that is to keep them at the class level instead of nesting them which was really making the Inspector ugly. I've realized that I could probably use Resources to get similar grouping behavior in the Inspector but when I tried it out it seems to have a bunch of caveats such as unneeded file clutter, tedious to set up, and complications setting the data at runtime. I now discovered that [ExportGroup] allows for grouping similar to how I would normally use subclasses, so that's pretty awesome! But it's still not truly ideal for certain use cases; say I want to quickly grab a certain subset of fields for creating a save file in code, I would like to be able to just read a subclass instance that holds the needed data (so I can serialize the whole object at once). I used to organize my entities that way for this purpose, but now I would have to parse through all of the fields one by one to get the same behavior. There could be plenty of other use cases as well for wanting to deal with arbitrary objects/subclasses and it would be really nice to see them in the Inspector. I will definitely need to do some research here to see what it would take to support this in the editor. |
Ran into this issue myself. I can't even use the ExportGroup attribute here, as I need to have multiple modifier and not just one. I would love to just use a C# struct for that and be able to export it, as I currently don't know how to do it otherwise. Again using a variety of Resources for that is out of the option, as this would result in hundreds of resources for something which should not be a resource at all. EDIT: |
Describe the project you are working on:
Just looking forward to using godot
Describe the problem or limitation you are having in your project:
Currently, exporting a field with type of a custom class or struct just doesn't work, godot can't seem to handle it.
The output prints 'unknown exported member type: [xyz]'
I tried to find workarounds, but just found more undesired behaviour.
First i tried using GetPropertyList to maybe add an editorplugin to draw them myself. But the return value doesn't include the scripts values. This also ruled out serializing the custom fields value into another field that godot can serialize (unity-like workaround), plus overriding _GetPropertyList also doesn't work correctly (setting usage for the property to NoEditor does not hide the property, desired equivalent is unity's [SerializeField, HideInEditor] combination).
Also, inheriting from ISerializationListener, which sounded promising (like unity's ISerializationCallback) did nothing, the callbacks didn't get invoked, but maybe that's even by design, although still limiting.
So there seems to be no feasible workaround.
The problem is that in c# it's quite common and often even necessary to group data via objects (or structs) for serialization, messaging etc. . And property editors should aid in editing those too (like in other popular engines)
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Implementing serialization/editing/[Export]ing custom classes will benefit every c# developer.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
It could work like regular property editing when presented to the user. Objects could be foldouts of properties when displayed in the inspector.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
It doesn't seem to be possible to be worked around as described above.
Is there a reason why this should be core and not an add-on in the asset library?:
This seems to requires changes in the engine.
The text was updated successfully, but these errors were encountered: