Skip to content

Discussing implementation and ideas for AdvancedSceneManager  #49

Closed
@VirtualMaestro

Description

@VirtualMaestro

Hey Joao and everyone interested in the Advanced scene manager!
Let's discuss the current version, possible improvements and features.
I'm not deep into the code base, so please correct me if something has no sense or just insane))

I think, first of all there should be a vision "how do I see using of the scene manager". (all the questions just to think about)

  1. Currently, a user must create an instance for the manager to use.
    Is there really a necessity for this? Or in another word, do I really need to have an instance?
    If I have an instance I can have multinstances. For what?
    If I have an instance (or instances) means I can remove the instance.
    In this case what should happen?
    What does it mean that instance was removed? Could it be that some scenes were related only to some instance and when this instance was removed these scenes also should be unloaded? Will it be easy to use such manager?
    Currently, there is a "Dispose" method that only clears up internal lists.
    So, should it be by the RAII principle (Resource Acquisition Is Initialization)?
    Probably not, since a scene is a resource like a prefab or texture that should be handled a ResourceManager that is higher level of manager that is out of the scope of a SceneManager. Or probably, this is not a bad idea. Need to think more))

  2. Is there a sense of not having all the active scenes in the manager?
    I'm referring to the constructor with the bool param and with the array of scenes.
    I see such lib as a full "replacement" of the Unity's SceneManager, so no need to use the standard one anymore. (quotes, because under the hood the lib uses the standard one).

  3. Simplicity-of-use is the most value for me. Plug and go. Without thinking "in which MonoBehaviour phase I have to use it? Does my manager know about all the loaded scenes?" Or, like we discussed in another thread this kind of hack could be implemented inside the manager: _sceneManager.UnloadAsync(SceneManager.GetSceneByPath(LoaderSceneInfo));
    Ideally, you can stupidly plug in and go without thinking about possible caveats.
    Probably, some of these simplicity could be solved by directly hooked into the Unity's player loop.
    (I did such in my kind of coroutine manager https://pastebin.com/HBhUeuf2 or here you can also find such solution https://youtu.be/ilvmOQtl57c)

  4. Continue the simplicity topic, can we say that all the manager's API (like loading/unloading) is asynchronous? Or in another word will be there synchronous API?
    Let's say we see that there are no sense to have a synchronous API, then we can simplify the API even more : AdvancedSceneManager.Load(), AdvancedSceneManager.Transition.
    Also, currently the API uses ValueTask everywhere, it implies that we have more situations when the methods (Load/Unload) return instant result. We need to figure out if this is not the case then better to use Task instead.
    E.g. I did a simple test where the manager on 'Scene_A' loads a 'Scene_B' by clicking UI button and unloads 'Scene_A' and then on "Scene_B" a user click another UI button to return back to Scene_A and unloads Scene_B. Everytime when by loading or unloading it takes 4 frames it means that it is loaded/unloaded asynchronous and in this case it is better to use Task instead of ValueTask.

  5. Hide if it is possible all the interfaces, structs, class that are not meant to be used by the users, so internal.

  6. One of the possible feature is a scenario or configurations for loading/unloading scenes. So, you have a configuration for loading of multiple scenes and unloading some other scenes. You could set this scenario and everything happens.
    I did something like this (I used it in a game), but it was tightly coupled to my framework. Here is an example how it looks like https://pastebin.com/WzmfpeG9.
    Not the best implementation, but to bring my idea https://github.com/VirtualMaestro/StubbUnity/blob/master/StubbUnity/StubbUnity/Src/StubbFramework/Scenes/Configurations/ScenesLoadingConfiguration.cs.

Again, these the brief thoughts, probably there are no sense or simply is wrong, probably some of them sparkle an idea to move on.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions