0 votes

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

in Engine by (521 points)

1 Answer

0 votes

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: https://github.com/godotengine/godot/issues/5988

by (28,880 points)
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.