-
-
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
SubClass as Custom types for export #3597
Comments
I agree, I'm currently unable to encapsulate data from an exported variable because I cannot make it a class. tool
extends Node
const Grid = preload("addons/terrain/array2d.gd")
# Error: export hint is not a type or resource
export(Grid) var save = null
func _ready():
save = Grid.create(8,5,1) Godot complains the type is not a resource, but mine actually inherit Resource. And anyways, I don't necessarily want it to be a Resource. |
There's a bit of a problem here: how will the inspector know how to handle the export? For built-in types there's code to handle each type and for resources there's the This should work with custom resources made by plugins (maybe it already does, as I haven't tested). |
Well, in my case the problem actually resides in saving, not in displaying the class in the inspector. If the inspector has no editor for that, it should simply ignore it or display nothing (like Dictionaries), thought a bit of reflection could help making a generic editor. |
It's not "weird", it's just the way it was designed. Of course it can be improved and it's mostly matter of how (hence my previous questioning). So far everybody lived with it this way. I don't like the idea of making export ignore custom types, since it's not what the user would expect and it would be frustrating. Also, don't think there's a default serialization for generic objects. That's another issue, but it would be required to save any kind of object in a |
Well, we can have subclasses export variables as well, can't we? |
I don't know about plugins but it's not working for simple custom resources. Now you can create a custom resource and expose it globally but you can't export it by its type, only using the Example
extends Resource
class_name CustomResource, "optional-icon.png" # 3.1
export(String) var some_data
extends Node
export(CustomResource) var custom_res This will show the following error: Parse Error: Expected a constant expression.
extends Node
const CustomResource = preload('res://CustomResource.gd')
export(CustomResource) var custom_res This will show the following error: Parse Error: Export hint not a resource type. This issue is a bit old but exporting custom resources would be really useful for 3.1. |
Would love to see this feature added. I imagine if the exported class is though of as a collection of types the Editor knows how to handle, I don't see why it couldn't behave the same way properties are set on built-in complex types in the Inspector. For example, a Spatial is shown in the editor as a list of Transform, Matrix, and Visibility, each which can be expanded and have their own set of attributes. I would love to be able to create my own settings like this. Ultimately, I believe it should be entirely feasible to generalize the Inspector so a tree structure can be used. |
This comment has been minimized.
This comment has been minimized.
@Shadowblitz16 Please don't bump issues without contributing significant new information; use the 👍 reaction button on the first post instead. |
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine. The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker. If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance! |
It'd be nice to be able to export a SubClass as a type of export and if you'd go into it and the exported variables from it would be accessible in the editor.
Related, #3586, is requesting Typed Arrays from gdscript, which I'd also like to see SubClasses show up there.
The text was updated successfully, but these errors were encountered: