Additive Async Multi-Scene Loading in Unity

Ойындар

Learn how to load multiple scenes asynchronously and additively, at the same time in Unity, with plenty of customization and a load screen. Load and Unload multiple scenes at the same time with less overhead and continuous progress reports!
NOTE: To follow along with this video, you need to use Unity 2023.1 or greater. Unity 2023.1 introduces support for a simplified asynchronous programming model using C# async and await keywords. Most of Unity’s asynchronous API supports the async/await pattern, including AsyncOperation.
docs.unity3d.com/2023.2/Docum...
If you are using a version of Unity before 2023, you can use extension methods from the Unity Utils repository to convert AsyncOperations to Tasks that you can await.
github.com/adammyhre/Unity-Ut...
Want to support me? 😀
Buy me a coffee! ko-fi.com/adammyhre
🔔 Subscribe for more Unity Tutorials / @git-amend
Discord: / discord
#unity3d #gamedev #indiedev
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 SceneReference Type
2:14 Scene Group Manager
9:20 Scene Loader
SceneReference Open Source
github.com/starikcetin/Eflatu...
Source code: github.com/adammyhre/Unity-In...
Assets Shown In This Video (Affiliate Links)
Cartoon Fantasy UI: assetstore.unity.com/packages...
Eole Foliage Shader: assetstore.unity.com/packages...
Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
Kronnect Beautify: assetstore.unity.com/packages...
Slate Cinematic Sequencer: assetstore.unity.com/packages...
Protofactor Animals: assetstore.unity.com/packages...
Follow me!
linktr.ee/gitamend

Пікірлер: 117

  • @git-amend
    @git-amend4 ай бұрын

    Hi everyone, I hope you find today's topic helpful! I personally (almost) always need to load more than one scene at a time when dealing with Additive scenes, so this kind of system makes life easier! We'll continue this topic by talking about Addressables in a future video, so click the 🔔 (and 👍!)

  • @Morphexe
    @Morphexe4 ай бұрын

    You are by far one of the best content for unity related stuff. I mean most channels are great for starters , or people learning, you give actual advanced concepts in a very digestible way. Good Job.

  • @git-amend

    @git-amend

    4 ай бұрын

    Happy to hear that! Thanks for the comment!

  • @alec_almartson
    @alec_almartson4 ай бұрын

    This is surely how Bigger games (scene systems) are Made With Unity 💡💯👍🏻 Thank You Sir, you're actually a great master, and your YT Channel really stands out from the crowd 💯👏🏻

  • @git-amend

    @git-amend

    4 ай бұрын

    You are most welcome

  • @NoTimeLeft_
    @NoTimeLeft_4 ай бұрын

    now THIS is near and dear to my heart as it is at the foundation of my project No Time Left. I love the effects you can create with a little additive async. Keep up the good fight! These videos are *chef kiss*

  • @git-amend

    @git-amend

    4 ай бұрын

    Yes, I agree! I look forward to watching your game develop!

  • @Krechevskoy
    @Krechevskoy4 ай бұрын

    Your channel is by far the most useful and relevant content for Unity, and it is always presented so clearly and succinctly. I wish I could follow you twice.

  • @git-amend

    @git-amend

    4 ай бұрын

    Wow, thanks!

  • @Fitz0fury
    @Fitz0fury4 ай бұрын

    The hits keep on coming! Thanks git-amend. About 2weeks ago i asked about additive scenes in your discord and here we are! Not sure if 100% coincidence or not but I couldn't be happier either way.

  • @git-amend

    @git-amend

    4 ай бұрын

    Only slight coincidence 😜

  • @anasmostefaoui3027
    @anasmostefaoui30274 ай бұрын

    your content is from the next level! thank you so much for every video you made so far, I hope your channel will grow and will see more of your advanced technical content.

  • @git-amend

    @git-amend

    4 ай бұрын

    Thanks! I've got some good ones planned for the near future!

  • @tahaaltndag3554
    @tahaaltndag35544 ай бұрын

    You are the best content creator for Unity by far! Thank you for everything! Would you think sharing a single github project that consists all of the systems and features?

  • @git-amend

    @git-amend

    4 ай бұрын

    Thanks for the kind words - and yes, one of these days when I get organized enough, I'll try to put together a complete library, including all the setup scripts, tooling and so on.

  • @vazzius
    @vazzius4 ай бұрын

    Congratz! Very interesting, clean and well done approach. For your exact system I would use the buildIndex 0 when checking for the Bootstrapper instead of the string, less prone to typo errors. For 3D games you might want to make the Enviroment category the active scene, as Unity will take the environment lighting settings from the active scene.

  • @git-amend

    @git-amend

    4 ай бұрын

    All good ideas, thanks for sharing!

  • @TChrisBaker
    @TChrisBaker4 ай бұрын

    Exactly the topic I needed help with. Thank you

  • @git-amend

    @git-amend

    4 ай бұрын

    Glad to hear that!

  • @antijulius
    @antijulius3 ай бұрын

    Such good timing on this one. Was just scratching my head, thinking there's gotta be a better way to handle these things... and sure enough, git-amend to the rescue!

  • @git-amend

    @git-amend

    3 ай бұрын

    Great! I think you'll like the next video all about adding support for loading Scenes as Addressables!

  • @Ironlionm4n
    @Ironlionm4n4 ай бұрын

    The most hyped I have been for a video

  • @git-amend

    @git-amend

    4 ай бұрын

    Glad to hear it!!

  • @echoness_
    @echoness_4 ай бұрын

    I have been digesting the gang of four these days anhd coupled the your vids which is perfect. 👏

  • @git-amend

    @git-amend

    4 ай бұрын

    Glad you like them!

  • @johanlindberg628
    @johanlindberg6284 ай бұрын

    Seriously staaaahp making such crazygood content! (Don't actually stop)

  • @git-amend

    @git-amend

    4 ай бұрын

    Thanks for the comment… no planned stops ahead!

  • @ceroenblanco
    @ceroenblanco4 ай бұрын

    8 years using unity and I still find scene management a very complex matter

  • @git-amend

    @git-amend

    4 ай бұрын

    Yes, isn’t that the truth !

  • @SanderDecleer
    @SanderDecleer4 ай бұрын

    What a nice way to handle multi-scene loading. I love using a bootstrapper scene and this will be a very good addition.

  • @git-amend

    @git-amend

    4 ай бұрын

    Glad you like it! Thanks!

  • @rofu8096
    @rofu80964 ай бұрын

    The new episode of my favorite series has arrived

  • @git-amend

    @git-amend

    4 ай бұрын

    Haha! Right on!

  • @alexandre2bi554
    @alexandre2bi5544 ай бұрын

    As always, really clean video ! I also saw that your unity inspector/hierarchy is really well organized, could you share in the future your folder organization, what package you use in a minimal project (i saw Console Pro but i guess you are using others!). Thanks and I can’t wait to see your next video!

  • @git-amend

    @git-amend

    4 ай бұрын

    Thanks, great suggestion!

  • @bluzenkk
    @bluzenkk4 ай бұрын

    looking forward to your next video~ cheers~

  • @git-amend

    @git-amend

    4 ай бұрын

    Great!

  • @lipee1663
    @lipee1663Ай бұрын

    This is an amazing video! Thank you so much for the effort and quality on the content man, your videos really help me understand advanced concepts that I'm facing right now. I have only one question about the use of await on SceneManager.LoadSceneAsync at 13:13 , I couldn't reproduce that on my unity version so I wanna ask how could you await for AsynchronousOperation like you did there. Thanks for the video again man! :)

  • @git-amend

    @git-amend

    Ай бұрын

    Glad to hear it! Full support for async operations isn't available until Unity 2023 and above. However, if you take a look in the Unity Utils repository there are several extension methods there that will help you convert an AsyncOperation to a Task or a Coroutine in older versions. github.com/adammyhre/Unity-Utils/tree/master/UnityUtils/Scripts/Extensions We've also made some changes to the repository, in particular to the Bootstrapper class, since this video came out, so make sure to check the repository for this video. Feel free to join the Discord, there is a forum related to this video and these exact questions.

  • @Ayman-dj9jm
    @Ayman-dj9jmАй бұрын

    Thank you for sharing. On 15:00 can please explain how the Task.Delay() method was reflecting the changes on the UI even though the progress.Report has not been executed yet?

  • @jtudela1
    @jtudela14 ай бұрын

    Your code that references PersistentSingleton... I'm assuming this is from another video? The Save/Load video? Nicely done btw, saved me from having to work this all out on my own and can adjust according to my own needs. Such as using this in collaboration with UI Toolkit instead of just canvas etc.

  • @git-amend

    @git-amend

    4 ай бұрын

    Yes, I have another video about Singletons. There is a copy of that class in the repository though: github.com/adammyhre/Unity-Inventory-System/tree/master/Assets/_Project/Scripts/Utility

  • @fleity
    @fleity4 ай бұрын

    Looking very much forward to the video on addressables. Those are always a huge pain.

  • @git-amend

    @git-amend

    4 ай бұрын

    Coming soon!

  • @connorjagielski6760
    @connorjagielski67602 ай бұрын

    For anyone who cares, I ended up making a scriptable object to contain all of the scene groups, then used Odin to make an editor window that loads the scene group scriptable object. That way if you're working on a different scene, you don't have to go to the bootstrapper scene if you want to change the scene groups. There's probably a better way to do it, but that worked for me!

  • @kpm25
    @kpm254 ай бұрын

    It's Adam right? Really appreciate the video. I always recommend your channel to fellow game-dev friends

  • @git-amend

    @git-amend

    4 ай бұрын

    Yup that’s me! Thanks so much!

  • @endihidir2087
    @endihidir20873 ай бұрын

    Very good topic thanks for this tutorial. I have a similar system like yours and I revised somethings according to your system. And I want to ask someting to you. Why don't you prefer Unitask instead of Task?

  • @git-amend

    @git-amend

    3 ай бұрын

    Thanks for the comment! Unitask is great, I just try to keep the YT videos as 'independant' as possible so it's more accessible for beginner/intermediate devs. I would encourage anyone to use Unitask if they are comfortable with it.

  • @raphaeljaggerd3585
    @raphaeljaggerd35854 ай бұрын

    awesome stuff

  • @git-amend

    @git-amend

    4 ай бұрын

    Thank you!

  • @raphaeljaggerd3585

    @raphaeljaggerd3585

    4 ай бұрын

    If your taking requests i think a series on re-creating systems from other games would be great like door kickers 2 movement or the dynamic interactive blood from the last of us 2@@git-amend

  • @git-amend

    @git-amend

    4 ай бұрын

    @@raphaeljaggerd3585 Good ideas, I'll write those down

  • @ekekw930
    @ekekw9303 ай бұрын

    Would love to see how you handle communication between the different scenes

  • @git-amend

    @git-amend

    3 ай бұрын

    I would likely use either Dependency Injection or a Service Locator to get references between scenes, and for messaging I would use a Message Bus. These are topics already covered on the channel, so I may not integrate those concepts here for the sake of new viewers.

  • @maciejzareba9563
    @maciejzareba956328 күн бұрын

    Minor suggestion. Add Init scene that has absolutly nothing but Load persistent scene additivly. Then once you load actual gameplay scene that hold's light and occlusion data unload this init scene. This way you trigger changing occlussion and light data. Unity has questionable way of changing those 2 data's. 1) Load new scene with those data 2) Set it as active 3) Unload previously set as active scene (at start our init scene) to trigger changing occlussion and light data.

  • @git-amend

    @git-amend

    28 күн бұрын

    That's a good idea. Another subscriber had an issue with that a few months ago, though more complex.

  • @NutBuster99
    @NutBuster99Ай бұрын

    Would you need a cancellation Token for the Task usage in this case?

  • @noordenonweer2138
    @noordenonweer2138Ай бұрын

    Are u sure, that u need in "UnloadScenes -> (sceneName.Equals(activeScene) || sceneName == "Bootstrapper")" to check "sceneName.Equals(activeScene)" , as this will ignore current loaded active scene in initial group and this scene will remain together with all another scenes in target scene group?

  • @MarushiaDark316
    @MarushiaDark3164 ай бұрын

    Would you recommend putting managers, your Save System, and singletons into the Bootstrapper scene such that they're always available to all scenes at all times and then just use Event Channels to communicate between them?

  • @git-amend

    @git-amend

    4 ай бұрын

    Yes, in this scenario it’s not necessary to use singletons anymore. The save system already binds on any scene load, and everything else could be supplied with DI or Service Locator, and you could message with a channel or bus.

  • @MarushiaDark316

    @MarushiaDark316

    4 ай бұрын

    @git-amend Reason I asked is cuz I can do bootstrapping and event channels, but the logic behind your injector, SL, and bus are still just outside my grasp. Still haven't graduated to advanced level quite yet, but I am learning.

  • @git-amend

    @git-amend

    4 ай бұрын

    @@MarushiaDark316 Gotcha - then you are good to go, channels will work fine!

  • @TheKr0ckeR
    @TheKr0ckeR4 ай бұрын

    Thank you, I generally have the problem of Setting Active Scene after loaded with async. For example I load my level asnyc, and after load: I SceneManager.SetActiveScene(sceneName), it "sometimes" gives error even if I do it after completion, when waiting async load. Have you ever had that problem? The reason i want to set active scene is i want to spawn my enemies inside "level" scene in hiearchy, so if it doesnt work, my enemies spawning in Main Scene

  • @git-amend

    @git-amend

    4 ай бұрын

    I have never encountered that issue - do you remember the exact error message?

  • @damonfedorick
    @damonfedorick4 ай бұрын

    Nice, I've been using a simple script that adds my UI scene on awake.

  • @git-amend

    @git-amend

    4 ай бұрын

    Cool, hope this one gives you more options!

  • @damonfedorick

    @damonfedorick

    4 ай бұрын

    @@git-amend what are you snaking on @10:45

  • @git-amend

    @git-amend

    4 ай бұрын

    @@damonfedorick Hah, Ramen probably. I thought about editing that out, but enough people ask me if I use AI voice over... this proves I'm a real person! 😃

  • @MarushiaDark316
    @MarushiaDark3164 ай бұрын

    This is really cool. Though I'm curious what's the point of using the Ratio = 1 in the report method, since division is expension. It seems like it's taking in a decimal float and returning the same decimal float. If you need to cast it, why not just cast it explicitly?

  • @git-amend

    @git-amend

    4 ай бұрын

    Good observation. I wanted to show the general usage of IProgress rather than worry about optimization.

  • @tobiasceres
    @tobiasceres3 ай бұрын

    Thank you for the video! A question if you don't mind. Maybe I didn't catch something important. In the Bootstrapper class "await" throws an error (even when I just Copy & Paste your stuff) The error: Type "UnityEngine.AsyncOperation" is not awaitable. Why does it work in the SceneLoader.cs but not in Bootstrapper.cs?

  • @git-amend

    @git-amend

    3 ай бұрын

    Being able to await the AsyncOperation type is a feature of Unity 2023.1 and above, so my guess is that you are on an earlier version. There is a discussion on Discord in the #programming-help section for people who don't want to use the latest version of Unity, and a link to the documentation in the description of this video. Hope that helps!

  • @tobiasceres

    @tobiasceres

    3 ай бұрын

    @@git-amend Ah, I see! Thank you very much for the fast answer. This will be the reason, because I am still on a 2022 version.

  • @MaryushXXVIII
    @MaryushXXVIII3 ай бұрын

    Where did you get such an unusual appearance of the transform in Inspector? Did you get this from some package or it's yours own implementation?

  • @git-amend

    @git-amend

    3 ай бұрын

    I use Better Transform and Better Mesh Renderer from Tiny Giant Studios, highly recommend: assetstore.unity.com/publishers/45848?aid=1101lw3sv

  • @Pedro_Marangon
    @Pedro_Marangon4 ай бұрын

    How does this system deals when I want to edit a specific level design scene? Will it get unloaded (due to the bootstrapper) and I'll need to play the game directly to that scene? I'd imagine it would be extremely tiredsome going through all of that just because I added a door or moved a platform by 3 units or something like that

  • @git-amend

    @git-amend

    4 ай бұрын

    In this case I would make the actual scene group you want to work with / test be a configurable setting for the Bootstrapper - maybe a Scriptable object or Player Settings.

  • @vazzius

    @vazzius

    4 ай бұрын

    You would have a tool that would load the bare minimum to load the level design in a playable state for testing. Or the level design scene will have a "Cold start" component, that when loaded, if it detects that it doesn't have the needed scenes it will load them. Many ways to do that without relying in the complete game systems to be able to edit.

  • @ObiWineKenobi
    @ObiWineKenobi4 ай бұрын

    You’ve got the voice to be a VO actor or on the radio 📺 📻

  • @git-amend

    @git-amend

    4 ай бұрын

    Too kind!

  • @V-post
    @V-post4 ай бұрын

    Do you have a video on separating out game logic into different scenes?

  • @git-amend

    @git-amend

    4 ай бұрын

    Not specifically on that topic, but there are a few videos on the channel that separate UI from Gameplay. Now that I’ve made this video, we’ll probably talk about it more.

  • @The-Bone-Zone
    @The-Bone-Zone2 ай бұрын

    Have you run into any platform issues with Linq? For example ios vs android or pc, etc?

  • @git-amend

    @git-amend

    2 ай бұрын

    I have not, but I do strongly advocate using the Profiles - and try to avoid LINQ in loops if possible, it's definitely something to watch for.

  • @Marlke
    @Marlke2 ай бұрын

    Hello everyone. Im working currently in an Android URP game for city simulation. It has tons of meshes, and loading the scene makes some devices to crash. Would you say that I can solve that issue by Async loading meshes?

  • @git-amend

    @git-amend

    2 ай бұрын

    More than likely, yes, asynchronous loading of meshes can mitigate crashes by spreading the loading process over multiple frames, reducing the instantaneous memory and processing load on devices. You would need to look into the logs, if any, to be sure that is the cause of the issue, but it sound probable.

  • @niuage
    @niuage4 ай бұрын

    When I had to implement this, I copied the way the ChopChop Unity community project did it. But that seems like it could be even more straightforward.

  • @git-amend

    @git-amend

    4 ай бұрын

    I forgot the Chop Chop project coved this, I'll have to take a look at what they did again. Thanks for reminding me, might find some improvements!

  • @kadircalloglu2848
    @kadircalloglu28484 ай бұрын

    I'm curious about something, how did you make the areas you clicked on black?

  • @git-amend

    @git-amend

    4 ай бұрын

    Which areas were you referring to?

  • @kadircalloglu2848

    @kadircalloglu2848

    4 ай бұрын

    When you right click on hierarchy but almost everywhere, i saw your background was black @@git-amend

  • @TChrisBaker

    @TChrisBaker

    4 ай бұрын

    ​@@kadircalloglu2848 that's just how unity's UI looks now in the newer versions of Unity

  • @TChrisBaker

    @TChrisBaker

    4 ай бұрын

    I recently upgraded to unity 2023.2 and noticed that

  • @kadircalloglu2848

    @kadircalloglu2848

    4 ай бұрын

    Ooo, I really tried it for a while, but it wasn't available as a beta version, thank you.@@TChrisBaker

  • @TheRubenazo
    @TheRubenazo7 күн бұрын

    Question, ¿What do I call when I want to load a new scene?

  • @git-amend

    @git-amend

    7 күн бұрын

    Pass a reference to a SceneGroup into the SceneGroupManager.LoadScenes method to load new scenes together. If you are talking about adding a scene without unloading the current scenes, you'll have to add some functionality for that.

  • @antijulius
    @antijulius3 ай бұрын

    Unity and Rider are flipping out on me because of await: "Type 'UnityEngine.AsyncOperation' is not awaitable" This happens with 'SceneManager.LoadSceneAsync' and 'Resources.UnloadUnusedAssets' - anyone else? I thought maybe it was a Rider issue but I'm getting the error in Unity as well.

  • @git-amend

    @git-amend

    3 ай бұрын

    You are probably not on a new enough version of Unity, check description for details.

  • @antijulius

    @antijulius

    3 ай бұрын

    @@git-amend Oh right! Didn't catch that. I'm on 22 LTS so that checks out. Thanks!

  • @elminsmajlovic4564

    @elminsmajlovic4564

    2 ай бұрын

    @@git-amend Is there an version 2022 equivalent for this line? Thanx alot

  • @git-amend

    @git-amend

    2 ай бұрын

    @@elminsmajlovic4564 I've added some Extension methods to the Unity Utils repo that can convert an AsyncOperation to a Task. You can give that a try, should help you out. github.com/adammyhre/Unity-Utils/blob/master/UnityUtils/Scripts/Extensions/AsyncOperationExtensions.cs await SceneManager.LoadSceneAsync("YourSceneName").AsTask(); There are a few other new extension methods there as well, such as converting a Task to a Coroutine. Check the latest commit for all those.

  • @elminsmajlovic4564

    @elminsmajlovic4564

    2 ай бұрын

    @@git-amend Thats cool. Is there a description how to use it?

  • @tiphaniestaub5025
    @tiphaniestaub50252 ай бұрын

    😅 Promo-SM

  • @git-amend

    @git-amend

    2 ай бұрын

    👋

  • @vanell3689
    @vanell3689Ай бұрын

    Hello, I enjoyed your lecture video. But I have one question: How did you implement the blurring of the surrounding area when the camera rotates? Is there a video related to this?

  • @git-amend

    @git-amend

    Ай бұрын

    That is actually just post processing Motion Blur... check it out here: docs.unity3d.com/Manual/PostProcessingOverview.html

  • @vanell3689

    @vanell3689

    Ай бұрын

    Thankyou!!!

Келесі