Disable exported variable on the editor

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fpicoral

Is there a way to disable (like read only, edit=false or something like that) an exported variable on the editor to avoid that:
enter image description here

:bust_in_silhouette: Reply From: Zylann

I don’t think there is an explicit way to make a variable read-only in the inspector, but you could try giving it a getter and a setter, where the setter simply does nothing, which would prevent edition of the variable. Problem is, I think it will also prevent it from being set too when the scene is loaded. This could be worked around by checking is_inside_tree() and Engine.editor_hint, because variables are set before the node is added to the tree. So if the node is in the scene tree AND in the editor, its value can’t be set. This is all workarounds so it may or may not work as you expect depending on the use cases you have.

On the other hand, if you just want to HIDE that variable but still have it saved in the scene file, there is another approach: don’t use export, and override _get_property_list(), _set() and _get() to specify flags manually, like shown in this issue: Ability to export a variable without showing it in the inspector · Issue #5988 · godotengine/godot · GitHub