You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Large scale project where I've had to refactor file names and locations quite a few times.
Describe the problem or limitation you are having in your project
Having to refactor all the preloads is clunky, and in general having to preload before instancing is also not the most elegant.
I saw that you could do
class_name SomeScene
and then do
SomeScene.new().
This works fine for built-in types. However, this is not the same as preloading then instancing custom classes/scenes (ie: SomeScene above)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Preloading user designated classes automatically, then having UserClass.instance() would be much more elegant in my opinion, and save a lot of time refactoring (as well as abstract away file paths, which is nice :)
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I'm thinking of two solutions:
Mark stuff to be preloaded with a keyword, eg global like so:
# Yay.gd
global class_name Yay # gdscript interpreter makes Yay a singleton or automatically preloads it in every other scene
# ...
# Main.gd
func _ready():
var yay = Yay.instance() # gdscript interpreter uses singleton or preloaded scene
yay.position = Vector2.ZERO
# ...
No marking of user defined classes, not sure how much of a pain it will be to code this version up
# Yay.gd
class_name Yay
# ...
# Main.gd
func _ready():
var yay = Yay.instance() # gdscript interpreter sees Yay.instance and preloads it
yay.position = Vector2.ZERO
# ...
If this enhancement will not be used often, can it be worked around with a few lines of script?
We could keep the status quo I guess :3
Is there a reason why this should be core and not an add-on in the asset library?
This is something that can't really be achieved with an add-on as far as I know.
The text was updated successfully, but these errors were encountered:
I'm also open to exploring and doing the PR myself, but not sure how to modify the gdscript interpreter, if anyone would like to give pointers on how to start doing that :)
Describe the project you are working on
Large scale project where I've had to refactor file names and locations quite a few times.
Describe the problem or limitation you are having in your project
Having to refactor all the preloads is clunky, and in general having to preload before instancing is also not the most elegant.
I saw that you could do
class_name SomeScene
and then do
SomeScene.new()
.This works fine for built-in types. However, this is not the same as preloading then instancing custom classes/scenes (ie: SomeScene above)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Preloading user designated classes automatically, then having UserClass.instance() would be much more elegant in my opinion, and save a lot of time refactoring (as well as abstract away file paths, which is nice :)
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I'm thinking of two solutions:
global
like so:If this enhancement will not be used often, can it be worked around with a few lines of script?
We could keep the status quo I guess :3
Is there a reason why this should be core and not an add-on in the asset library?
This is something that can't really be achieved with an add-on as far as I know.
The text was updated successfully, but these errors were encountered: