-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Cyclic reference of Scene and its Script #27048
Comments
As I understood, it was not really supposed to work in 3.0 and it was the source of other bugs which are now fixed in 3.1. You should indeed use Did you measure its speed? IMO it is not slower, the only difference is when loading will happen, but depending on how you instance this scene in your game, there might not be a difference. |
I think it is not comfortable to use. In not all cases You can replace
with
What if there are static functions in script that use instancing? Then You should write the following to work:
It is rather dirty, I think. |
If there are static functions you want to use, you can preload the script, not the whole scene. |
Closing in favor of godotengine/godot-proposals#460, as feature proposals are now tracked on the Godot proposals repository. |
Godot version:
3.1
Issue description:
Consider a scene
SomeScene.tscn
and its scriptSomeScene.gd
.In 3.0 one could write
and use scene instancing in code. But now this is forbidden, and the project doesn't work.
I understand that there is real cyclic dependence, but I did not find anything on how to bypass this problem correctly according to code style guide. I don't want to use
load
instead ofpreload
because it is slower, and really not needed logically. Several scenes can have the same script, but in real life almost every scene has a unique script resource, and it is convenient to be able to address to self scene in script resource using compiler abilities (preload
).Steps to reproduce:
Create
SomeScene.tscn
andSomeScene.gd
, attach script to scene then add line to .gd file:The text was updated successfully, but these errors were encountered: