poohcom1 / godot-private-exports

A Godot addon that lets you set access modifier for exported variables!

Home Page:https://godotengine.org/asset-library/asset/2136

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add default access modifier for all properties

Araraura opened this issue · comments

Is it possible to add a feature that will change the default access modifier for all properties? I want to have everything private by default and simply change them to protected or public when I need them

I haven't been actively using this addon in my projects, so it's unlikely that I'll have time to implement and fully test this as a feature.

But as a workaround, you can update line 43 in addons/private-exports/lib/core.gd to change the default value:

func get_access_modifier(object: Object, property: StringName) -> AccessModifier:
var scenes := _get_scene_data(object)
# Loop backward, in case some property is somehow set in a desecendant
for i in range(len(scenes) - 1, -1, -1):
var scene := scenes[i]
if property in scene.metadata and scene.metadata[property]:
return scene.metadata[property]
return AccessModifier.Public

If that doesn't work, you might also need to update this line in addons/private-exports/controls/access_modifier_button.gd:

var _modifier := Core.AccessModifier.Public

This one change should set the default modifier for all unset properties going forward, but for scenes that you've already opened, it might not work.