Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript fails to export variables properly from within a tool script, whenever a singleton is accessed within that script. #6886

Closed
RabbitB opened this issue Oct 21, 2016 · 6 comments

Comments

@RabbitB
Copy link

RabbitB commented Oct 21, 2016

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

@RebelliousX
Copy link
Contributor

RebelliousX commented Nov 15, 2016

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"

@jandrewlong
Copy link
Contributor

jandrewlong commented Dec 29, 2016

As a workaround, I've been using:

onready var global = get_node("/root/global")

for my singleton name 'global'

@RebelliousX
Copy link
Contributor

RebelliousX commented Dec 29, 2016

@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"

@27thLiz
Copy link
Contributor

27thLiz commented Aug 8, 2017

Duplicate of #4236

@27thLiz 27thLiz marked this as a duplicate of #4326 Aug 8, 2017
@27thLiz 27thLiz closed this as completed Aug 8, 2017
@27thLiz 27thLiz marked this as a duplicate of #4236 Aug 8, 2017
@lucaslcode
Copy link
Contributor

@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

@lucaslcode
Copy link
Contributor

New bug: #29492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants