The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I want to export NodePath which only some specific class can be selected to prevent selecting an invalid class and also easier on the eyes, as I saw some built-in nodes did it.
Also doing for _get_property_list() will be good too because I'm using this right now.
like this
like this

Godot version 3.4.1.stable
in Engine by (82 points)
edited by

2 Answers

0 votes
Best answer

Found out.

You can do this by using _get_property_list()

func _get_property_list() -> Array:
    return [

At 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

by (82 points)
edited by
–1 vote

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:

by (1,406 points)

Hmm, I meant more like specifying a node you can only select from a NodePath screen.
Like this animation tree player node here
Like this animation tree player node here

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?

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?

enter image description here
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.
enter image description here

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 classname for your resource starting with "A" so that it will show up in the top of the list when creating a new resource instance.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.