You use the type required in the export statement, e.g.
# Opening the inspector dropdown may result in an
# extremely long list of possible classes to create, however.
# Therefore, if you specify an extension of Resource such as:
export(AnimationNode) var resource
# The drop-down menu will be limited to AnimationNode and all
# its inherited classes.
Taken from here:
Hmm, I meant more like specifying a node you can only select from a NodePath screen.
Like this animation tree player node here
Multirious | 2021-12-19 08:36
I-I don’t understand what does this suppose to do with specifying Node for exported nodepath. Are you replying to the wrong post in anyways?
Multirious | 2021-12-19 10:34
Using your custom type in the export ensures the editor only allows that type (or types derived from it). Did you follow the examples and/or try the solution?
spaceyjase | 2021-12-19 11:13
Is this correct?
It’s only worked for resources type, I’m exporting NodePath for specific Node
I’ve wanted to do something like this:
export(NodePath, TextureRect) var texture_rect_only_path: NodePath
I’ve tried your code
export(AnimationNode) var resource and it doesn’t work as I requested to do.
Multirious | 2021-12-19 12:56
Please note that the example of exporting a Resource subclass available in the docs IS MISLEADING.
It would work IF the Resource subclass is a C++ class, but this certainly doesn’t work with scripts as you have seen yourself. Maybe exporting scripted resources on godot 4 already works as expected and the docs are referring to godot 4, or maybe the docs are indeed referring to C++ subclassing instead of scripting subclassing (and the description should be more explicit of this). But as anyone can test on the latest stable release (3.4.2 as I’m writing), it is not possible to export a custom script resource. The best workaround is just using a class_name for your resource starting with “A_” so that it will show up in the top of the list when creating a new resource instance.
gnumaru | 2021-12-29 14:36
You can do this by using
func _get_property_list() -> Array:
hint=35 is not in the docs; I found it from here
I have no idea how to do it for export key-word, though. Trying
export(NodePath, 'Node') var test: NodePath
return an error
Parse Error: Type "NodePath" can't take hints.
Advance export docs