Additive Async Multi-Scene Loading in Unity

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 123

  • @git-amend
    @git-amend  8 месяцев назад +17

    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 8 месяцев назад +30

    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  8 месяцев назад +2

      Happy to hear that! Thanks for the comment!

  • @Krechevskoy
    @Krechevskoy 8 месяцев назад +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  8 месяцев назад +1

      Wow, thanks!

  • @alec_almartson
    @alec_almartson 8 месяцев назад +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  8 месяцев назад +1

      You are most welcome

  • @NoTimeLeft_
    @NoTimeLeft_ 8 месяцев назад +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  8 месяцев назад

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

  • @vazzius
    @vazzius 8 месяцев назад +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  8 месяцев назад +2

      All good ideas, thanks for sharing!

  • @tahaaltndag3554
    @tahaaltndag3554 8 месяцев назад +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  8 месяцев назад +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.

  • @connorjagielski6760
    @connorjagielski6760 6 месяцев назад +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!

  • @Fitz0fury
    @Fitz0fury 8 месяцев назад +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  8 месяцев назад +1

      Only slight coincidence 😜

  • @gloups157
    @gloups157 2 месяца назад

    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  2 месяца назад +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!

  • @antijulius
    @antijulius 8 месяцев назад

    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  8 месяцев назад +2

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

  • @SanderDecleer
    @SanderDecleer 8 месяцев назад

    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  8 месяцев назад

      Glad you like it! Thanks!

  • @anasmostefaoui3027
    @anasmostefaoui3027 8 месяцев назад

    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  8 месяцев назад +1

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

  • @rofu8096
    @rofu8096 8 месяцев назад +2

    The new episode of my favorite series has arrived

    • @git-amend
      @git-amend  8 месяцев назад +1

      Haha! Right on!

  • @echoness_
    @echoness_ 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад +1

      Glad you like them!

  • @ceroenblanco
    @ceroenblanco 8 месяцев назад +1

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

    • @git-amend
      @git-amend  8 месяцев назад +1

      Yes, isn’t that the truth !

  • @TChrisBaker
    @TChrisBaker 8 месяцев назад +1

    Exactly the topic I needed help with. Thank you

    • @git-amend
      @git-amend  8 месяцев назад

      Glad to hear that!

  • @fleity
    @fleity 8 месяцев назад

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

  • @johanlindberg628
    @johanlindberg628 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад

      Thanks for the comment… no planned stops ahead!

  • @Ayman-dj9jm
    @Ayman-dj9jm 5 месяцев назад

    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?

  • @kpm25
    @kpm25 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад

      Yup that’s me! Thanks so much!

  • @Ironlionm4n
    @Ironlionm4n 8 месяцев назад

    The most hyped I have been for a video

    • @git-amend
      @git-amend  8 месяцев назад +1

      Glad to hear it!!

  • @jtudela1
    @jtudela1 8 месяцев назад

    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  8 месяцев назад +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

  • @alexandre2bi554
    @alexandre2bi554 8 месяцев назад

    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  8 месяцев назад +2

      Thanks, great suggestion!

  • @bluzenkk
    @bluzenkk 8 месяцев назад

    looking forward to your next video~ cheers~

  • @maciejzareba9563
    @maciejzareba9563 5 месяцев назад

    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  5 месяцев назад

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

  • @lipee1663
    @lipee1663 6 месяцев назад

    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  6 месяцев назад +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.

  • @ekekw930
    @ekekw930 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад

      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.

  • @tobiasceres
    @tobiasceres 8 месяцев назад

    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  8 месяцев назад +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 8 месяцев назад

      @@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 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад

      Cool, hope this one gives you more options!

    • @damonfedorick
      @damonfedorick 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад +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! 😃

  • @noordenonweer2138
    @noordenonweer2138 5 месяцев назад

    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?

  • @niuage
    @niuage 8 месяцев назад

    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  8 месяцев назад

      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!

  • @NutBuster99
    @NutBuster99 5 месяцев назад

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

  • @TheKr0ckeR
    @TheKr0ckeR 8 месяцев назад

    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  8 месяцев назад

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

  • @The-Bone-Zone
    @The-Bone-Zone 6 месяцев назад

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

    • @git-amend
      @git-amend  6 месяцев назад +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.

  • @MarushiaDark316
    @MarushiaDark316 8 месяцев назад

    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  8 месяцев назад +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 8 месяцев назад

      @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  8 месяцев назад

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

  • @MarushiaDark316
    @MarushiaDark316 8 месяцев назад

    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  8 месяцев назад

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

  • @roronoazaoxl
    @roronoazaoxl 4 месяца назад

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

    • @git-amend
      @git-amend  4 месяца назад +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 3 месяца назад

      @@git-amend Thank you~

  • @MaryushXXVIII
    @MaryushXXVIII 8 месяцев назад

    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  8 месяцев назад

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

  • @endihidir2087
    @endihidir2087 8 месяцев назад

    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  8 месяцев назад +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.

  • @Marlke
    @Marlke 7 месяцев назад

    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  7 месяцев назад

      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.

  • @ObiWineKenobi
    @ObiWineKenobi 8 месяцев назад

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

  • @Pedro_Marangon
    @Pedro_Marangon 8 месяцев назад

    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  8 месяцев назад

      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 8 месяцев назад

      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.

  • @TheRubenazo
    @TheRubenazo 4 месяца назад

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

    • @git-amend
      @git-amend  4 месяца назад

      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.

  • @V-post
    @V-post 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад +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 8 месяцев назад

    awesome stuff

    • @git-amend
      @git-amend  8 месяцев назад

      Thank you!

    • @raphaeljaggerd3585
      @raphaeljaggerd3585 8 месяцев назад

      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  8 месяцев назад +1

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

  • @kadircalloglu2848
    @kadircalloglu2848 8 месяцев назад

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

    • @git-amend
      @git-amend  8 месяцев назад

      Which areas were you referring to?

    • @kadircalloglu2848
      @kadircalloglu2848 8 месяцев назад

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

    • @TChrisBaker
      @TChrisBaker 8 месяцев назад

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

    • @TChrisBaker
      @TChrisBaker 8 месяцев назад

      I recently upgraded to unity 2023.2 and noticed that

    • @kadircalloglu2848
      @kadircalloglu2848 8 месяцев назад +1

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

  • @antijulius
    @antijulius 7 месяцев назад

    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  7 месяцев назад +1

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

    • @antijulius
      @antijulius 7 месяцев назад

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

    • @elminsmajlovic4564
      @elminsmajlovic4564 7 месяцев назад

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

    • @git-amend
      @git-amend  7 месяцев назад +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 7 месяцев назад

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

  • @tiphaniestaub5025
    @tiphaniestaub5025 7 месяцев назад

    😅 Promo-SM

  • @vanell3689
    @vanell3689 5 месяцев назад

    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  5 месяцев назад

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

    • @vanell3689
      @vanell3689 5 месяцев назад

      Thankyou!!!