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

Add Autoloads to the Scene tree for easier signal connection management #4993

Open
Flynsarmy opened this issue Jul 27, 2022 · 8 comments
Open

Comments

@Flynsarmy
Copy link

Describe the project you are working on

I have an AudioManager, LevelManager, global Event bus, UnlockablesManager all autoloaded. Some of these (namely the global Event bus) have a lot of signals defined. These signals are connected to and used by a large number of scenes in my game.

Describe the problem or limitation you are having in your project

Not so much a limitation as a difficulty. Global event busses are very commonly used pattern in Godot projects however their major downside is that it can be difficult to tell what they're connecting to and all connections must be manually made in code.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose adding a collapsible list of autoloads to the top of the Scene tree. These nodes could be clicked on and signal connections made in the same way you currently can with any child node of your scene.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I propose adding a collapsible list of autoloads to the Scene tree like so:
GlobalEventBus

Signals from these autoloads would work identically to signals from any node in your tree. You click the autoload class, go to the Node tab and connect a signal. An autoloads Node tab would only show connections for the currently loaded Scene.

Scene trees can become quite full in more complex scenes and on larger projects there can be a lot of autoloads, so for this reason I've suggested a collapsible list to easily get the new rows out of sight.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This proposal is commonly worked around with the caveat that it's not quite as intuitive or easy to use as the GUI-based signal system.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not familiar enough with the engine to know if it's possible for this to be added with an add-on. I believe the feature should be core because it leverages existing functionality in a new way to make a common use-case more intuitive.

@YuriSizov
Copy link
Contributor

See also #1694

@mieldepoche
Copy link

I had a proposal idea about having a "root scene" dock displaying a scene view where the root is a Viewport (or Window in 4.0) and adding children to it would register autoloads without having to go through the dedicated interface.
These nodes would interact with the inspector like regular nodes so they could all be configured this way (if they export properties for example).
This would have provided root viewport configuration in the usual inspector and a clear view of what the root actually is and where autoloads live in the tree.

Maybe some of these ideas can be salvaged.

@me2beats
Copy link

me2beats commented Jul 30, 2022

I like the idea to see singletons in the SceneTreeEditor, I also imagine you can work with singletons almost just like with a regular node, like change properties in Inspector especially exported properties (export var). This could make singletons more reusable — you can use a singleton in other projects without changing the script but still tweak something using export vars

@me2beats
Copy link

me2beats commented Jul 30, 2022

One thing I am worry about is that in the proposed screenshots it kinda looks like singletons belong to scenes, this can be confusing for new users

@thornySoap
Copy link

(#6927) Another advantage would be that Autoloads could be directly referenced to nodes that have a Node-property exported.

@jinyangcruise
Copy link

I like the idea to see singletons in the SceneTreeEditor, I also imagine we can see singletons in the ConnectDialog.
something like this:
image

@shak2
Copy link

shak2 commented Jun 23, 2024

I like this idea.

But also, add a tick box in project settings to do this. Some people don't use autoloads regularly and it would bloat their trees.

@JimArtificer
Copy link

The most interesting application of this to me is the enhancement to the "Connect a Signal" dialog. Being able to connect to an event bus or another type of autoload singleton would save time and reduce the need for small scripts.

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

8 participants