Operating system or device - Godot version:
Windows 10 Pro - Godot 2.1.0.0
Issue description (what happened, and what was expected):
GDScript fails to export variables properly from a tool script, whenever a singleton is accessed within that script.
Extensive details and how to reproduce here: Export var bug when using singletons within a tool
Happens also in latest master branch.
It is worth mentioning, disabling some parts of code while in editor, like using:
if (get_tree().is_editor_hint()):
set_fixed_process(false)
To disable any code that mentions the autoload singleton, that doesn't work too. "[Autoload name] identifier not found"
As a workaround, I've been using:
onready var global = get_node("/root/global")
for my singleton name 'global'
@jandrewlong I am not really sure that will work, since by doing that, according to my knowledge, you are instantiating a new object, you are not using the same shared "singleton" global object. But I could be wrong, that could be a reference to the singleton object, besides, singleton should mean only one object to exist only. Edit: Scratch what I said, I was sleepy or something, singleton objects are created once and referenced when being accessed, so clearly get_node() will return a reference. I will check your solution, if it works, it would be great to simplify the code of some nodes, because my current workaround is awkward.
My current awkward workaround is to create child node with script that has "tool" keyword, which that script read export variables from parent object. That way changing parent's export variables will effectively change the child script through signals "setget"
Duplicate of #4236
@Hinsbart can you reopen this (or should I make another issue?) because this is still affecting me on 3.1.1, and the workaround posted by @jandrewlong doesn't work for me
New bug: #29492
Most helpful comment
As a workaround, I've been using:
onready var global = get_node("/root/global")for my singleton name 'global'