Replies: 2 comments 4 replies
-
See also: |
Beta Was this translation helpful? Give feedback.
-
Personally I prefer to have a single If I need reference to any node inside of the autoload scene I use singleton pattern in it like so: class_name GameManager
static var instance: GameManager
func _ready() -> void:
instance = self GameManager instance can be accessed globally from any script with Same exact singleton pattern works for nodes that aren't in autoload, for example main player controller that spawns dynamically. It's simple and covers a lot of usecases which is why a lot of games ship with that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Autoloads are very useful, but the inability to access their
@export
variables is a bit limiting. One alternative is to have them as children of the first game scene, but that would defeat the purpose of autoloading.I don't think there's a technical limitation that makes autoloads incompatible with
@export
variables, so I think it's mainly an interface issue ?With a well-designed and easily accessible interface for this, it would be a powerful tool for configuring configurable test situations. I haven't thought in detail what form this could take, but I can look for ideas.
Edit: I forgot it was possible to do this via an autoload scene, but I find tedious having two files instead of one per autoload, plus having to open each scene independently.
The idea behind the proposal was to make autoloads a useful tool for changing the configuration of global game parameters, but maybe this isn't the right place to do that.
I find that, as it stands, no solution really convinces me for this. Being able to launch a scene via F6 isn't ideal. I often end up with a Main.tscn scene that contains the
@export
variables. The advantage is that I know everything is in the main scene, the disadvantage is that it's very dependent on the current project and less easily reusable.I'm not exactly sure what form this should take, but I feel like we could have a place to efficiently configure project's global settings. I should probably open a discussion specifically on this topic.
Beta Was this translation helpful? Give feedback.
All reactions