Private Exports

by poohcom1

23

Godot Private Exports

A Godot addon that adds access modifiers to exported variables in scenes. This can be used to prevent changes to exported variables that are only meant to be modified in the base scene or reduce clutter from the inspector.

Example of inspector

Requirements

Godot 4.2 dev 4+

Usage

  1. Install the addon from the AssetLib.
  2. Activate the plugin from Project Settings > Plugin.
  3. Navigate to the root node of a scene and the inspector will now contain access modifier buttons.
  4. Update exports access modifier to Private or Protected
  5. Navigate to a tree where the scene is instantiated. The Private exports will now be hidden!

FAQ

Q: Why aren't the access modifiers updating when I updated the script?

A: Since these are stored as metadata in the scene, sometimes the loaded scene may go out of sync with the file. Try saving and reopening the scene to see if it resolves the issue.

Q: Why don't I see the access modifier buttons?

A: Make sure you're at the root node of a scene. Since only root node exports are visible in other scenes, only these variables can have access modifiers.

Q: Why are access modifiers from one scene not the same as another scene with the same script?

A: The addon is designed around scenes, not scripts. Scenes can be treated as "classes" and scenes in other trees are treated as "instances". This is the reason Protected variables apply to inherited scenes, not inherited scripts. If you are looking for an addon that hides properties based on scripts, check out Hide Private Properties, which hides properties that begins with an underscore.

Access Modifiers

  • Public: Public exports are always visible.
  • Private: Private exports are only visible in the base scene.
  • Protected: Protected exports are only visible in the base scene and its inheritors.
Actor.tscn Player.tscn (extends Actor) Level.tscn
Example of base scene Example of inherited scene Example of ext scene

Private and protected exports can be used to fine-tune how exports are shown in other scenes.

Editor Settings

Setting Description Default
Display Mode Always: modifier always shown Selected: only shown on selected properties Modified: only shown on modified and selected properties Always

Development

Testing

Most testing is done by gdUnit4. However, testing is_overwriting_default is not possible with gdUnit because it uses Script.get_property_default_value, which only works in the editor. To cover this, extra tests has been writen as an EditorScript in test/manual_test.gd.

Version

1.2.1

Engine

4.2

Category

Tools

Download

Version1.2.1
Download

Support

If you need help or have questions about this plugin, please contact the author.

Contact Author