+2 votes

For instance, when you have a Node2D selected in the Scene, the Inspector has two collapsible sections: Transform, and Ordering. Several variables are hidden until you click those words, and then you can see all of that section's variables.

It would be very convenient if I could organize my own script's variables in this same kind of way. How would I do it?

Godot version v4.0.beta1.official [20d667284]
in Engine by (66 points)

2 Answers

+4 votes
Best answer

The thing @jgodfrey said probably worked in 3.x but does not work in 4.0.
If you try it, you will see stuff in the inspector, but you won't be able to edit values.

Bright side: There is a much easier way to do this in 4.0beta.
And after finding the name of the thing in the 4.0 beta release page gif, I was able to search the documentation for it, specifically.

https://docs.godotengine.org/en/latest/classes/[email protected]?highlight=export_group#class-gdscript-annotation-export-group

For a quick answer to my own question, you can now use this:

@export var FirstOne : bool = false
@export var SecondOne : bool = false

@export var ThirdOne : bool = false
@export var FourthOne : bool = false

Leaving it in that order makes the stuff magically work the way it ought in the editor.

by (66 points)
edited by

I'm not a 4.0 user ATM, but... very nice. ;^)

+1 vote

Sounds like you're after the Grouping Properties mechanism. It's documented in the Grouping Properties section here:

Below is an example from the docs, slightly modified to place a few properties in the same group. In addition to the code snippet, you'll need to make the script a tool script (add the tool keyword to the top of the code) so the below method will be called in the editor...

func _get_property_list():
    var properties = []
        name = "Rotate",
        type = TYPE_NIL,
        hint_string = "rotate_",

    # Example of adding to the group
        name = "rotate_angle",
        type = TYPE_REAL

        name = "rotate_speed",
        type = TYPE_REAL

    # This property won't get added to the group
    # due to not having the "rotate_" prefix.
        name = "trail_color",
        type = TYPE_COLOR
    return properties
by (19,300 points)

This looked like what I was after. When I do this code (with minor variations, because I have to for 4.0), the stuff shows up in the inspector....but it appears to not be edit-able?

I am not sure why.

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.