Additive Async Multi-Scene Loading in Unity

Sdílet
Vložit
  • čas přidán 28. 08. 2024

Komentáře • 122

  • @git-amend
    @git-amend  Před 5 měsíci +15

    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
    @Morphexe Před 5 měsíci +25

    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  Před 5 měsíci +1

      Happy to hear that! Thanks for the comment!

  • @alec_almartson
    @alec_almartson Před 5 měsíci +6

    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 💯👏🏻

  • @gloups825
    @gloups825 Před 15 hodinami

    I was going to ask you to make a video about bootstrapping a game and I came across this nugget! Thank you so much, I'd like to credit you for my game as I've learned so much from you ;).

    • @git-amend
      @git-amend  Před 14 hodinami +1

      Glad to hear it! Credit is not really necessary, but I do like hearing about games that my subscribers release so please keep me posted!

  • @Krechevskoy
    @Krechevskoy Před 5 měsíci +3

    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.

  • @NoTimeLeft_
    @NoTimeLeft_ Před 5 měsíci +3

    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  Před 5 měsíci

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

  • @tahaaltndag3554
    @tahaaltndag3554 Před 5 měsíci +2

    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  Před 5 měsíci +3

      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
    @vazzius Před 5 měsíci +3

    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  Před 5 měsíci +2

      All good ideas, thanks for sharing!

  • @Fitz0fury
    @Fitz0fury Před 5 měsíci +1

    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  Před 5 měsíci +1

      Only slight coincidence 😜

  • @ceroenblanco
    @ceroenblanco Před 5 měsíci +1

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

    • @git-amend
      @git-amend  Před 5 měsíci +1

      Yes, isn’t that the truth !

  • @rofu8096
    @rofu8096 Před 5 měsíci +2

    The new episode of my favorite series has arrived

  • @antijulius
    @antijulius Před 5 měsíci

    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  Před 5 měsíci +2

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

  • @SanderDecleer
    @SanderDecleer Před 5 měsíci

    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  Před 5 měsíci

      Glad you like it! Thanks!

  • @anasmostefaoui3027
    @anasmostefaoui3027 Před 5 měsíci

    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  Před 5 měsíci +1

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

  • @connorjagielski6760
    @connorjagielski6760 Před 4 měsíci

    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!

  • @TChrisBaker
    @TChrisBaker Před 5 měsíci +1

    Exactly the topic I needed help with. Thank you

  • @echoness_
    @echoness_ Před 5 měsíci

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

  • @kpm25
    @kpm25 Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci

      Yup that’s me! Thanks so much!

  • @Ironlionm4n
    @Ironlionm4n Před 5 měsíci

    The most hyped I have been for a video

  • @jtudela1
    @jtudela1 Před 5 měsíci

    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  Před 5 měsíci +1

      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

  • @lipee1663
    @lipee1663 Před 3 měsíci

    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  Před 3 měsíci

      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.

  • @johanlindberg628
    @johanlindberg628 Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci

      Thanks for the comment… no planned stops ahead!

  • @alexandre2bi554
    @alexandre2bi554 Před 5 měsíci

    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  Před 5 měsíci +2

      Thanks, great suggestion!

  • @Ayman-dj9jm
    @Ayman-dj9jm Před 3 měsíci

    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?

  • @fleity
    @fleity Před 5 měsíci

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

  • @maciejzareba9563
    @maciejzareba9563 Před 2 měsíci

    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  Před 2 měsíci

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

  • @bluzenkk
    @bluzenkk Před 5 měsíci

    looking forward to your next video~ cheers~

  • @noordenonweer2138
    @noordenonweer2138 Před 3 měsíci

    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?

  • @NutBuster99
    @NutBuster99 Před 3 měsíci

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

  • @ekekw930
    @ekekw930 Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci

      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.

  • @roronoazaoxl
    @roronoazaoxl Před měsícem

    you code editor is really cool. is that VS code? what plugin do you use?

    • @git-amend
      @git-amend  Před měsícem +1

      I use JetBrains Rider as my Editor. You can try it for free right now with the early access program: www.jetbrains.com/rider/nextversion/

    • @roronoazaoxl
      @roronoazaoxl Před měsícem

      @@git-amend Thank you~

  • @endihidir2087
    @endihidir2087 Před 5 měsíci

    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  Před 5 měsíci +1

      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.

  • @ObiWineKenobi
    @ObiWineKenobi Před 5 měsíci

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

  • @MaryushXXVIII
    @MaryushXXVIII Před 5 měsíci

    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  Před 5 měsíci

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

  • @MarushiaDark316
    @MarushiaDark316 Před 5 měsíci

    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  Před 5 měsíci

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

  • @tobiasceres
    @tobiasceres Před 5 měsíci

    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  Před 5 měsíci +1

      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 Před 5 měsíci

      @@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.

  • @damonfedorick
    @damonfedorick Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci

      Cool, hope this one gives you more options!

    • @damonfedorick
      @damonfedorick Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci +1

      @@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
    @MarushiaDark316 Před 5 měsíci

    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  Před 5 měsíci +1

      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 Před 5 měsíci

      @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  Před 5 měsíci

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

  • @The-Bone-Zone
    @The-Bone-Zone Před 3 měsíci

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

    • @git-amend
      @git-amend  Před 3 měsíci +1

      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
    @Marlke Před 4 měsíci

    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  Před 4 měsíci

      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
    @niuage Před 5 měsíci

    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  Před 5 měsíci

      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!

  • @TheKr0ckeR
    @TheKr0ckeR Před 5 měsíci

    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  Před 5 měsíci

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

  • @TheRubenazo
    @TheRubenazo Před 2 měsíci

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

    • @git-amend
      @git-amend  Před 2 měsíci

      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.

  • @Pedro_Marangon
    @Pedro_Marangon Před 5 měsíci

    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  Před 5 měsíci

      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 Před 5 měsíci

      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.

  • @V-post
    @V-post Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci +1

      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.

  • @raphaeljaggerd3585
    @raphaeljaggerd3585 Před 5 měsíci

    awesome stuff

    • @git-amend
      @git-amend  Před 5 měsíci

      Thank you!

    • @raphaeljaggerd3585
      @raphaeljaggerd3585 Před 5 měsíci

      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  Před 5 měsíci +1

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

  • @kadircalloglu2848
    @kadircalloglu2848 Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci

      Which areas were you referring to?

    • @kadircalloglu2848
      @kadircalloglu2848 Před 5 měsíci

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

    • @TChrisBaker
      @TChrisBaker Před 5 měsíci

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

    • @TChrisBaker
      @TChrisBaker Před 5 měsíci

      I recently upgraded to unity 2023.2 and noticed that

    • @kadircalloglu2848
      @kadircalloglu2848 Před 5 měsíci +1

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

  • @antijulius
    @antijulius Před 5 měsíci

    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  Před 5 měsíci +1

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

    • @antijulius
      @antijulius Před 5 měsíci

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

    • @elminsmajlovic4564
      @elminsmajlovic4564 Před 4 měsíci

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

    • @git-amend
      @git-amend  Před 4 měsíci +1

      @@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 Před 4 měsíci

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

  • @tiphaniestaub5025
    @tiphaniestaub5025 Před 4 měsíci

    😅 Promo-SM

  • @vanell3689
    @vanell3689 Před 3 měsíci

    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  Před 3 měsíci

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

    • @vanell3689
      @vanell3689 Před 3 měsíci

      Thankyou!!!