Additive Async Multi-Scene Loading in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ม.ค. 2025

ความคิดเห็น • 124

  • @git-amend
    @git-amend  10 หลายเดือนก่อน +19

    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 10 หลายเดือนก่อน +35

    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  10 หลายเดือนก่อน +2

      Happy to hear that! Thanks for the comment!

  • @Krechevskoy
    @Krechevskoy 10 หลายเดือนก่อน +5

    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  10 หลายเดือนก่อน +1

      Wow, thanks!

  • @alec_almartson
    @alec_almartson 10 หลายเดือนก่อน +7

    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  10 หลายเดือนก่อน +1

      You are most welcome

  • @NoTimeLeft_
    @NoTimeLeft_ 10 หลายเดือนก่อน +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  10 หลายเดือนก่อน

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

  • @Fitz0fury
    @Fitz0fury 10 หลายเดือนก่อน +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  10 หลายเดือนก่อน +1

      Only slight coincidence 😜

  • @tahaaltndag3554
    @tahaaltndag3554 10 หลายเดือนก่อน +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  10 หลายเดือนก่อน +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 10 หลายเดือนก่อน +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  10 หลายเดือนก่อน +2

      All good ideas, thanks for sharing!

  • @antijulius
    @antijulius 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +2

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

  • @anasmostefaoui3027
    @anasmostefaoui3027 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +1

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

  • @gloups157
    @gloups157 4 หลายเดือนก่อน

    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  4 หลายเดือนก่อน +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!

  • @johanlindberg628
    @johanlindberg628 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Thanks for the comment… no planned stops ahead!

  • @rofu8096
    @rofu8096 10 หลายเดือนก่อน +2

    The new episode of my favorite series has arrived

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +1

      Haha! Right on!

  • @echoness_
    @echoness_ 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +1

      Glad you like them!

  • @SanderDecleer
    @SanderDecleer 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

      Glad you like it! Thanks!

  • @TChrisBaker
    @TChrisBaker 10 หลายเดือนก่อน +1

    Exactly the topic I needed help with. Thank you

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Glad to hear that!

  • @Ironlionm4n
    @Ironlionm4n 10 หลายเดือนก่อน

    The most hyped I have been for a video

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +1

      Glad to hear it!!

  • @connorjagielski6760
    @connorjagielski6760 9 หลายเดือนก่อน +1

    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!

  • @ceroenblanco
    @ceroenblanco 10 หลายเดือนก่อน +1

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +1

      Yes, isn’t that the truth !

  • @kpm25
    @kpm25 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Yup that’s me! Thanks so much!

  • @bluzenkk
    @bluzenkk 10 หลายเดือนก่อน

    looking forward to your next video~ cheers~

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Great!

  • @lipee1663
    @lipee1663 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน +1

      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 8 หลายเดือนก่อน

    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 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Coming soon!

  • @alexandre2bi554
    @alexandre2bi554 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +2

      Thanks, great suggestion!

  • @jtudela1
    @jtudela1 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +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

  • @NutBuster99
    @NutBuster99 8 หลายเดือนก่อน

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

  • @noordenonweer2138
    @noordenonweer2138 7 หลายเดือนก่อน

    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?

  • @roronoazaoxl
    @roronoazaoxl 6 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  6 หลายเดือนก่อน +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 6 หลายเดือนก่อน

      @@git-amend Thank you~

  • @tobiasceres
    @tobiasceres 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +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 10 หลายเดือนก่อน

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

  • @Pedro_Marangon
    @Pedro_Marangon 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      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.

  • @TheKr0ckeR
    @TheKr0ckeR 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

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

  • @MarushiaDark316
    @MarushiaDark316 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +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 10 หลายเดือนก่อน

      @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  10 หลายเดือนก่อน

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

  • @The-Bone-Zone
    @The-Bone-Zone 8 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  8 หลายเดือนก่อน +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 9 หลายเดือนก่อน

    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  9 หลายเดือนก่อน

      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.

  • @ekekw930
    @ekekw930 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      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.

  • @MaryushXXVIII
    @MaryushXXVIII 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

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

  • @MarushiaDark316
    @MarushiaDark316 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

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

  • @maciejzareba9563
    @maciejzareba9563 7 หลายเดือนก่อน

    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  7 หลายเดือนก่อน

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

  • @TheRubenazo
    @TheRubenazo 6 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  6 หลายเดือนก่อน

      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
    @antijulius 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +1

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

    • @antijulius
      @antijulius 10 หลายเดือนก่อน

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

    • @elminsmajlovic4564
      @elminsmajlovic4564 9 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  9 หลายเดือนก่อน +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 9 หลายเดือนก่อน

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

  • @endihidir2087
    @endihidir2087 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน +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.

  • @kadircalloglu2848
    @kadircalloglu2848 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Which areas were you referring to?

    • @kadircalloglu2848
      @kadircalloglu2848 10 หลายเดือนก่อน

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

    • @TChrisBaker
      @TChrisBaker 10 หลายเดือนก่อน

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

    • @TChrisBaker
      @TChrisBaker 10 หลายเดือนก่อน

      I recently upgraded to unity 2023.2 and noticed that

    • @kadircalloglu2848
      @kadircalloglu2848 10 หลายเดือนก่อน +1

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

  • @V-post
    @V-post 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +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.

  • @Brightfield
    @Brightfield 19 วันที่ผ่านมา

    @git-amend
    why do you want to keep the "active scene" in the unload scenes method?
    if that is the main menu scene, or the active level you are transitioning from, dont you want to remove that?
    some of my scripts are extending your SingletonPersistant. they are moved to the DontDestroyOnLoad hidden scene. can you elaborate on
    i) how you handle retaining connection to other classes like the SceneLoader?
    ii) why we both use the Singleton DontDestroyOnLoad and keep the Bootstrapper for persistence?

  • @damonfedorick
    @damonfedorick 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Cool, hope this one gives you more options!

    • @damonfedorick
      @damonfedorick 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน +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! 😃

  • @raphaeljaggerd3585
    @raphaeljaggerd3585 10 หลายเดือนก่อน

    awesome stuff

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Thank you!

    • @raphaeljaggerd3585
      @raphaeljaggerd3585 10 หลายเดือนก่อน

      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  10 หลายเดือนก่อน +1

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

  • @niuage
    @niuage 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

      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!

  • @ObiWineKenobi
    @ObiWineKenobi 10 หลายเดือนก่อน

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

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Too kind!

  • @tiphaniestaub5025
    @tiphaniestaub5025 9 หลายเดือนก่อน

    😅 Promo-SM

    • @git-amend
      @git-amend  9 หลายเดือนก่อน

      👋

  • @vanell3689
    @vanell3689 7 หลายเดือนก่อน

    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  7 หลายเดือนก่อน

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

    • @vanell3689
      @vanell3689 7 หลายเดือนก่อน

      Thankyou!!!