DEV Community

Cover image for Organize Your Godot Exports with export_category in Godot 4
Azad Kshitij
Azad Kshitij

Posted on

Organize Your Godot Exports with export_category in Godot 4

Have you ever wondered how to neatly categorize your exported variables in Godot? The answer lies in the export_category keyword, a fantastic new feature introduced in Godot 4. It allows you to group your exported variables, maintaining organization and tidiness in your scripts.

YouTube

How to Use export_category:

It's remarkably simple. Just place @export_category("YourCategoryName") before the @export keyword. For instance, if you're working on a player script and want to create a category called "Movement," it's as easy as:

@export_category("Movement")
@export var speed = 10
@export var jump_height = 5
Enter fullscreen mode Exit fullscreen mode

With this, you'll have a "Movement" category neatly displayed in your inspector, containing all related exported variables. To add more categories, simply place @export_category above your desired exported variables.

@export_category("Player Info")
@export var name = "Bit Of Code"
Enter fullscreen mode Exit fullscreen mode

Why Use export_category:

  • Keep your projects organized, even with numerous exported variables.
  • Enhance script readability and maintainability.
  • Simplify tweaking and fine-tuning during development.

Conclusion:

I hope you found this tutorial helpful and discovered a new way to organize your Godot projects. If you did, please give it a like and if you prefer a video version watch the short to better understand export_category

Top comments (0)