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 👍!)
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.
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.
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 💯👏🏻
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*
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.
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?
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.
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!
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.
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 ;).
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!
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.
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?
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.
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
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!
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.
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! :)
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.
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.
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?
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!
@@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! 😃
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?
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
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?
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.
@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.
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?
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?
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.
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?
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.
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
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.
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.
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.
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.
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
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.
@@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.
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?
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 👍!)
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.
Happy to hear that! Thanks for the comment!
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.
Wow, thanks!
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 💯👏🏻
You are most welcome
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*
Yes, I agree! I look forward to watching your game develop!
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.
All good ideas, thanks for sharing!
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?
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.
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!
Can you share how you did this?
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.
Only slight coincidence 😜
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 ;).
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!
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!
Great! I think you'll like the next video all about adding support for loading Scenes as Addressables!
What a nice way to handle multi-scene loading. I love using a bootstrapper scene and this will be a very good addition.
Glad you like it! Thanks!
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.
Thanks! I've got some good ones planned for the near future!
The new episode of my favorite series has arrived
Haha! Right on!
I have been digesting the gang of four these days anhd coupled the your vids which is perfect. 👏
Glad you like them!
8 years using unity and I still find scene management a very complex matter
Yes, isn’t that the truth !
Exactly the topic I needed help with. Thank you
Glad to hear that!
Looking very much forward to the video on addressables. Those are always a huge pain.
Coming soon!
Seriously staaaahp making such crazygood content!
(Don't actually stop)
Thanks for the comment… no planned stops ahead!
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?
It's Adam right? Really appreciate the video. I
always recommend your channel to fellow game-dev friends
Yup that’s me! Thanks so much!
The most hyped I have been for a video
Glad to hear it!!
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.
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
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!
Thanks, great suggestion!
looking forward to your next video~ cheers~
Great!
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.
That's a good idea. Another subscriber had an issue with that a few months ago, though more complex.
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! :)
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.
Would love to see how you handle communication between the different scenes
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.
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?
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!
@@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.
Nice, I've been using a simple script that adds my UI scene on awake.
Cool, hope this one gives you more options!
@@git-amend what are you snaking on @10:45
@@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! 😃
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?
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.
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!
Would you need a cancellation Token for the Task usage in this case?
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
I have never encountered that issue - do you remember the exact error message?
Have you run into any platform issues with Linq? For example ios vs android or pc, etc?
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.
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?
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.
@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.
@@MarushiaDark316 Gotcha - then you are good to go, channels will work fine!
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?
Good observation. I wanted to show the general usage of IProgress rather than worry about optimization.
you code editor is really cool. is that VS code? what plugin do you use?
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/
@@git-amend Thank you~
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?
I use Better Transform and Better Mesh Renderer from Tiny Giant Studios, highly recommend:
assetstore.unity.com/publishers/45848?aid=1101lw3sv
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?
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.
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?
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.
You’ve got the voice to be a VO actor or on the radio 📺 📻
Too kind!
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
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.
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.
Question, ¿What do I call when I want to load a new scene?
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.
Do you have a video on separating out game logic into different scenes?
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.
awesome stuff
Thank you!
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
@@raphaeljaggerd3585 Good ideas, I'll write those down
I'm curious about something, how did you make the areas you clicked on black?
Which areas were you referring to?
When you right click on hierarchy but almost everywhere, i saw your background was black @@git-amend
@@kadircalloglu2848 that's just how unity's UI looks now in the newer versions of Unity
I recently upgraded to unity 2023.2 and noticed that
Ooo, I really tried it for a while, but it wasn't available as a beta version, thank you.@@TChrisBaker
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.
You are probably not on a new enough version of Unity, check description for details.
@@git-amend Oh right! Didn't catch that. I'm on 22 LTS so that checks out. Thanks!
@@git-amend Is there an version 2022 equivalent for this line? Thanx alot
@@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.
@@git-amend Thats cool. Is there a description how to use it?
😅 Promo-SM
👋
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?
That is actually just post processing Motion Blur... check it out here: docs.unity3d.com/Manual/PostProcessingOverview.html
Thankyou!!!