Scene Manager in Unity (Loading Unity Tutorial)

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

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

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  5 ปีที่แล้ว +38

    Does the Loading Bar work in your games? I'm still trying to figure out how Unity splits scenes for loading, would be great to have a very gradual loading bar.

    • @thanos_n9s145
      @thanos_n9s145 5 ปีที่แล้ว +4

      What about circular loading bar??
      Or continue playing song on loading screen which was running on last scene
      On another words, Can you show me is it possible or not
      If any song is playing on first scene, before I jump on another scene I'll get loading screen with that song which was running on last scene without being stopped
      Hope you understand what I actually mean

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +8

      Make sure your game object that is playing the music is not Destroyed on Load with the function DontDestroyOnLoad(gameObject);
      docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials 5 ปีที่แล้ว +10

      Unity loads the scene for 0%-90% and then the final 10% is for the scene activation. (So for tiny scenes like that it will load to 90% within one frame.) I would recommend perhaps lerping the fill amount so that it will smoothly increase upwards and look nicer overall.

    • @thanos_n9s145
      @thanos_n9s145 5 ปีที่แล้ว

      Thanks

    • @rickloyd8208
      @rickloyd8208 5 ปีที่แล้ว +2

      Dapper Dino - Coding Tutorials can you share short example with using lerping? Thanks

  • @Liberator-vl4zm
    @Liberator-vl4zm 2 หลายเดือนก่อน

    Somehow I made this 15 minute tutorial a 2 hour long one. (Great tutorial btw)

  • @0_Vio
    @0_Vio 5 ปีที่แล้ว +9

    I was about to searchin for this now but you uploaded it already, Lol ty.

  • @Whaiitran3106
    @Whaiitran3106 3 ปีที่แล้ว +3

    A differente way...
    Create a scriptable object to keep the scene name intended to switch.
    Create generic Scene with a method in Start that will read the scriptable object to get the scene name and call a load scene.

  • @rickloyd8208
    @rickloyd8208 5 ปีที่แล้ว +2

    Man, you have original way to do even simple things. I used prefab as scene loader but yours is much better... I could never thought to use new scene to load another scene... hahaha That's why, even when topic seems to be known, it's better to watch your video!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Glad to hear the video has been useful!

  • @ДанРыжков
    @ДанРыжков 3 ปีที่แล้ว

    The best tut..!)) Clear and easy with no overengineering))) My head is saved!))

  • @EtherasFox
    @EtherasFox 4 ปีที่แล้ว +10

    You made this way more complicated than it needs to be. I realize you don't like CoRoutines, but you can get rid of all that delegate hackiness by just having a yield return wait until next frame in a coroutine. You're already including it, so why not use it??
    Also, a dummy class just to have access to monobehaviour? You could just make it a static method on a loader class that extends monobehavior. You don't need to instantiate it to access static methods, so the method signature should be the same.

    • @robbywilliams6391
      @robbywilliams6391 3 ปีที่แล้ว +1

      calm down

    • @oldcat1790
      @oldcat1790 2 ปีที่แล้ว

      I prefer using asset called "more effective coroutines". It allows to use coroutines without relying on monobehaviour of any kind.

  • @maxfun6797
    @maxfun6797 2 ปีที่แล้ว

    GUA. excellente tutorial. this is what I'm talking about. I came to learn about loading, but ended up learning a thing about Actions as well.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +2

      I'm glad you liked it! Actions/Delegates are super useful, I also covered them in more detail here if you want to learn more th-cam.com/video/3ZfwqWl-YI0/w-d-xo.html

  • @7415_Gamer
    @7415_Gamer 3 ปีที่แล้ว

    Thanks bro, this helped me.

  • @somethingnew4650
    @somethingnew4650 3 ปีที่แล้ว

    Thank you so much i been searching about the best way to load scenes and you make it easy for me 😊

  • @kleioscope
    @kleioscope 3 ปีที่แล้ว +1

    Nice demonstration of the unity3D loading progress bug ! :P

  • @micaiahstevens8840
    @micaiahstevens8840 5 ปีที่แล้ว +1

    Really nice video on the Load Scene and how to chain events together to make sure you have your assets loaded.

    • @micaiahstevens8840
      @micaiahstevens8840 5 ปีที่แล้ว

      The reason it's at 90% isn't because of some fancy 90% loading frequency.
      (this will come later)
      Its cause you preset the loading bar to load in at 90%.
      I would maybe suggest this line on your LoadingProgressBar class
      // Awake
      image = transform.GetComponent();
      image.fillAmount = 0f;
      That way you can be sure to start at 0f load fill.
      . . . AND you need to add the LoadingProgressBar script to your image.
      This might be off camera, but is also not added in the code download.

    • @micaiahstevens8840
      @micaiahstevens8840 5 ปีที่แล้ว

      I've been playing around with this, and I'd say (Unitys Code is broken.) It gets only to 90%. if you allowActivation to be false, it won't even finish the load and have to run a >= 0.9 as presented in this documentation.
      docs.unity3d.com/ScriptReference/AsyncOperation-progress.html
      The isDone never gets sets to true. (With activation) I think maybe you could do an additive scene, and then set to 100% and fade in and out to swap scenes. With a fade image covering your background scene. BUT then you have to account for a scene being loaded, but not ready and not running, sounds and gameplay, SUCH as most games do anyways.
      Overall its a bad part on Unity.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Yeah I tried many things to try to understand how unity breaks scenes apart and I just couldn't do it. I made a script that created thousands of game objects on start, went 0 to 90; Tried creating textures and copying millions of pixels, 0 to 90; Tried a massive scene that I imported from one of the unity graphics projects, 0 to 90;
      So I really don't understand how the core engine breaks scenes apart for loading.

  • @Johanna77777-z
    @Johanna77777-z 2 ปีที่แล้ว +2

    Make sure you add "using System;" to your loader so Action works!

  • @my_0ne
    @my_0ne 3 ปีที่แล้ว

    Thank You for this nice video

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

    hello codemonkey, I have question about different time scales for different additive scene.
    is it possible to pause or slow down a scene while maintaining 1.0f scale for another additive scene?
    I mainly have a normal scene in which monsters will chase players and perform tasks and a battle scene.
    As you can imagine I need the normal scene to pause when i enter battle scene, but when I finish battle I was to resume everything in the normal scene.
    Is there a way to do that?

  • @JeongHwanKim-bl2ur
    @JeongHwanKim-bl2ur 5 ปีที่แล้ว +6

    I use this. Arbitrary, but works.
    if (image.fillAmount < Loader.GetLoadingProgress())
    {
    image.fillAmount += 0.01f // depends on the size of the scene you want to load
    }

  • @bramvanwambeke1859
    @bramvanwambeke1859 5 ปีที่แล้ว +3

    Ur a godsent :3 i was really struggling with scenes in unity, great video.

  • @de-souzapatrice1859
    @de-souzapatrice1859 ปีที่แล้ว

    Hi !
    Good content.
    Let me know, why do you use [6:34] a delegate (onLoaderCallback) while you can handle the current scene with a simple member variable like you done in KitchenChaos tutorial.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว +1

      Remember there are always many ways to solve any problem, I don't remember how I handled it differently in Kitchen Chaos but there's always more than one solution.

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

    @CodeMonkeyUnity
    When the game start, I press play button timer starts and finishes, then the scene gets loaded MM. During gameplay, when i pause game and press the Main Menu button, the scene gets loaded MM and again, i press play button to start the game but this time timer doesnt start

  • @moviesexplanationshindi4951
    @moviesexplanationshindi4951 3 ปีที่แล้ว +1

    I want to make 3d game .in game I want to make different levels if level 1 completed player need to jump to level to so how to make this type of levels

  • @BirdPowerTV
    @BirdPowerTV 5 ปีที่แล้ว +5

    Been watching some of your videos over the last few days, as im interested in getting to learn the Unity engine. I just wanted to say thank you so much for making these amazing videos on your channel, keep it up dude. Got one question one program do you use to create your textures for your assets in Battle Royale Tycoon ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Thanks, glad you like the videos!
      I draw all my sprites in Photoshop.

  • @Sabhari_
    @Sabhari_ ปีที่แล้ว

    11:21 I have a doubt. How are you calling LoadSceneAsync() within Loader class but inside a component thats part of the LoadingMonoBehaviour class?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว

      Coroutines need to be run on a MonoBehaviour, and the LoadSceneAsync function is static so it can be accessed from anywhere

  • @antonai367
    @antonai367 5 ปีที่แล้ว +1

    Thank You!

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

    The code works perfectly, but I've got 2 issues. I have a main GameScene, where I switch to another scene for playing a puzzle minigame. After that I switch back to the previous scene, but the scene gets completly resettet. How can I store and save the data of the main GameScene?
    The other issue is that I want to implement a crossfade transition between the scenes, but I can't implement the animation in a static class.

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

      Yup when you load a scene it will load exactly as that scene was saved, if you spawn objects dynamically and reload the scene they won't be there. You need to save that data somewhere and then load it when reloading that scene. Simplest way to save data is with a static field, alternatively you can use the same logic for saving to a file th-cam.com/video/6uMFEM-napE/w-d-xo.html

  • @Sammy-cv1jm
    @Sammy-cv1jm 5 ปีที่แล้ว +1

    First! love your videos!

  • @subhasishkolay8398
    @subhasishkolay8398 4 ปีที่แล้ว +1

    I really want to know about changing the image of canvases of all the scenes on click of a button which is present at the main menu scenes it's like applying a theme in the game but I am totally confused and there's not a single tutorial available anywhere

  • @mauznemo
    @mauznemo 3 ปีที่แล้ว

    when I use the scene manager, my scene is always black, as if the camera is being rendered twice, what can I do?

  • @bhushandeshmukh7731
    @bhushandeshmukh7731 4 ปีที่แล้ว +1

    What to do if I want change orientation while changing scene,
    Where to write orientation related code so that it will look smooth

  • @maxdrvn
    @maxdrvn 4 ปีที่แล้ว

    In 2:09, when I type Loader, it doesn't appear on the dropdown; it replaces it by some other name instead. Why is it?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Did you name your class Loader? Is it in the same project files?

    • @maxdrvn
      @maxdrvn 4 ปีที่แล้ว

      @@CodeMonkeyUnity Everything looks fine for me. I guess it's easier to just download your files and replace from there :S

  • @ilcane8785
    @ilcane8785 ปีที่แล้ว

    Hello Code Monkey, I've watched hundreds of your (awesome) tutorials, but there's one basic topic I don't think you've expanded upon much: what are the best practices for handling the relationship between scenes?
    For example I've never seen you use the singleton pattern that persists objects through scenes, is it because it's a bad idea? Or is it simply because your tutorials usually only have a single scene?
    How would you handle something as basic as moving a Player object from Scene 1 to Scene 2 while persisting some of its data?
    Or how would you get in Scene 2 the information that the Player entered from Scene 1 and not Scene 3?
    By the way I'm commenting on this video since it's the only one I could remember where you broached the topic, but if I've missed another could you point me to it?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว

      In my own games I normally just have one Game Scene so I don't necessarily have too much direct experience with that topic.
      For transferring data between scenes, like which Save file to load, for that I normally just use a simple static field so that's one option.
      Another option is to use a game object and just mark it as DontDestroyOnLoad(); that way it will persist even as you change scenes so you can use that to transfer any data. Making that object a singleton would make it very simple.
      So for the player, if you have just one player you could use a static field "private Scene lastPlayerScene;" or a dedicated script to handle cross-scene references and store some regular field there.

    • @ilcane8785
      @ilcane8785 ปีที่แล้ว

      Got it, that's pretty much what I was thinking myself.
      Thanks a lot for the answer.

  • @velladezzy
    @velladezzy 7 หลายเดือนก่อน +1

    I did everything but it says a Null has no reference :(

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  7 หลายเดือนก่อน +1

      Use Debug.Log to find out what is null unitycodemonkey.com/video.php?v=5irv30-bTJw

  • @baldingfox77558
    @baldingfox77558 4 ปีที่แล้ว

    Thanks for making this. how did you make the pixel art for this backround? it looks nice.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      It's a free texture I grabbed from the Asset Store. It was many years ago so I can't remember exactly which one it is.

    • @baldingfox77558
      @baldingfox77558 4 ปีที่แล้ว

      @@CodeMonkeyUnity is it possible to make your own backround?

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

    maybe im stupid idk, but i dont understand why it works... if the line "SceneManager.LoadScene(scene.ToString());" STARTS the loading of the 2nd level, why, when it's called on the first frame of the loading-scene, the actual loading is already completed? What am i missing?
    In my imagination it would switch from the loading to the level scene and still do the freeze...

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

      Yes it does freeze but it freezes on the loading scene, so it freezes while the screen is saying "Loading" which makes it clear to the player what is happening in the background.
      So it loads the Loading scene, waits 1 frame just to have it rendered onto the screen, then loads the final scene.

  • @adakathawa1556
    @adakathawa1556 3 ปีที่แล้ว

    In getLoadingProgress if the asyncOperation is null then you should return 0 not 1. and you missed to add LoadingPrgress script to the progress bar image

    • @ElvishJumpSuit
      @ElvishJumpSuit ปีที่แล้ว

      I agree with both points.....(return 1 not 0) Otherwise it can sometimes briefly show 100% first, then drop back which looks weird. Unless we both missed something.

  • @1234yokee
    @1234yokee 4 ปีที่แล้ว

    hello sir. I have a problem. My project have Scene 1 and Scene 2.I preloaded Scene 1 In the Scene 2. But Scene 1 UI show on the Scene 2. So how to hide it? Help me Sir,thank you(sorry for my english skill)

  • @domd511
    @domd511 4 ปีที่แล้ว

    I didn't find a video on your channel about Singletons ; Do you use singletons for a GameManager class for example? or is that a paradigm that you stay away from?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      I do use singletons but be careful not to abuse them. Usually just a simple property so I haven't done a dedicated video on them
      public static GameManager Instance { get; private set; }

  • @DARK_AMBIGUOUS
    @DARK_AMBIGUOUS 2 ปีที่แล้ว

    I have a question. I’m trying to make a level editor for my game and I want to make it where you press a button and it creates a new scene and then switches to that scene and instantantiats everything needed for the level editor. I have the level editor already finished in a separate scene but how do I make it so you click on a button and it like create a new scene or duplicates the level editor scene. I am using visual scripting and I I tried using the “create scene” unit but It won’t work, it won’t let me connect it to “load scene async” because there are no “scene manager, load scene async” units that have a scene input, they all either have an input for the scene name or build index and whenever I connect the “create scene” scene output to “set scene name” scene input. And then the scene name output from the “set scene name” unit to the “load scene async” scene name input, and then run my game. The unit just turns red and it doesn’t work. I’ve been stuck on this all day

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      You don't dynamically create a scene, you just make a script that runs on that final scene, and that script constructs the level. All you need is for that script to know what the level should look like. In Visual Scripting perhaps use application variables that persist between scenes

  • @thejumpergaming4699
    @thejumpergaming4699 4 ปีที่แล้ว

    im in unity 2020 and i did all of your code that you said to do but when i press my button it goes to the loading screen fine and the bar fills all the way, but after that it just stays on the loading screen and doesnt go to my game scene. i dont know what i did wrong, so any help would be appreciated

  • @onikishin3396
    @onikishin3396 ปีที่แล้ว

    For some reason I get a NullReference when I run the game. I checked my scene name and the name of the button that has the GameSceneUI script

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว +1

      On what line? Use Debug.Log to find out what is null unitycodemonkey.com/video.php?v=5irv30-bTJw

    • @onikishin3396
      @onikishin3396 ปีที่แล้ว

      @@CodeMonkeyUnity I figured it out. It was a really simple mistake. I never attached your Button_UI script to the button. Thanks for the help

  • @torontogamestudio2991
    @torontogamestudio2991 2 ปีที่แล้ว

    How can I trigger next scene after last enemy is destroyed?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      Depends on how you're handling the enemies. If you have some kind of health system like my own then you can listen to the event when the enemy dies and trigger the scene change unitycodemonkey.com/video.php?v=tf8NhUgORQg

  • @uditsharma158
    @uditsharma158 ปีที่แล้ว

    Hi,
    How can i pass the scene names dynamically ?
    scenes = new string[]{"Assets/*unity"}
    Something like this.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว

      pass to where? One way to hold data through scene changes is make it static
      Or keep the data in some object that has DontDestroyOnLoad();

    • @uditsharma158
      @uditsharma158 ปีที่แล้ว

      @@CodeMonkeyUnity I was trying to get a list of scenes to select whenever i use the batchmode command.
      Thanks a lot for your help.

  • @tanay_sankhe
    @tanay_sankhe 5 ปีที่แล้ว +1

    After coding part, in Unity it says,'The name SceneManagement does not exist in the current context'. What am I suppose to do ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      You need to add the using statement 1:05

    • @arisaek7764
      @arisaek7764 5 ปีที่แล้ว

      @@CodeMonkeyUnity can u pls tell me how u make the Using UnityEngine.SceneManager; from grey (unable) info colored (enable) I cant understand how to make it colored so I the loadscene code is valid..that virtual studio..cancels my code for no reason.. ;/ pls help me out I looked all over the internet so I can make tis work u are my last hope!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      @@arisaek7764 What version of visual studio are you using? You need to install the Visual Studio Unity Tools for it to recognize unity code. Download the most recent visual studio version

    • @arisaek7764
      @arisaek7764 5 ปีที่แล้ว

      @@CodeMonkeyUnity latest version on both unity and virtual studio.. virtual studio 2019

  • @alucksay6538
    @alucksay6538 5 ปีที่แล้ว

    thank you

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

    what version of unity? all the tutorials I have read or watched has"using UnityEngine.SceneManagement;" but my version of unity kicks out the error that SceneManagement does not exist in that namespace. I'm still in unity 4.9 - thats as far as I could upgrade without trashing my very old project

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

      That version is ancient, why are you using it? Unity is free, just download the latest LTS version

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

      @@CodeMonkeyUnity I started this game on version 3.5 many years ago. Many many years ago. It's just something I dabble in over the years. I upgraded periodically and got to version 4.9. But when 5.0 came out and I upgraded EVERYTHING broke. The code syntax or something changed because unity spit out too many error messages for the game to even play - too many to go back and change everything. My goal is to someday finish it and it's about 3/4 of the way there. I've done builds and it plays fine so I am pushing forward with 4.9 on this project. The load time isn't so long that I need to preload or use scene management but if it was available I would

  • @grantscott1686
    @grantscott1686 3 ปีที่แล้ว

    Not sure why but when I type SceneManager.LoadScene into visual studio, it doesn't like that and says "CS0117: 'SceneManager' does not contain a definition for 'LoadScene'"... Why is that?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      Do you have a different class also named SceneManager?
      You should be using UnityEngine.SceneManagement.SceneManager

  • @IRONADEE
    @IRONADEE 4 ปีที่แล้ว

    I need help i copyed the same code and it wont work this is the code i usedusing System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManager;
    public class SceneSwitch : MonoBehaviour {
    public enum Scene {
    Scene 2,
    }
    public static void Load(Scene scene) {
    SceneManager.LoadScene(scene.ToString()};
    }
    }
    Please tell me if i did anything wrong

  • @hassanhass3787
    @hassanhass3787 4 ปีที่แล้ว

    Thanks for the great tutorial! I followed it all along but at around 13:40 I think you forgot to assign the "LoadingProgressBar.cs" Script to the loadingbar gameobject. The progressbar only seems to work because you set the "Fill Amount" to fixed 0.928. But after fixing this mistake another error occurs: When the loading scene gets loaded the progressbar is shortly 100% filled even when the initial fill amount is set to 0. Solution could be to only render the progress bar after the loading scene is fully loaded?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      I've tried tons of approaches and none of them really worked, it really depends on how Unity decides to split up your scene for loading so don't think there's anything you can do to make the loading bar perfect.

  • @kinda_history_nerd
    @kinda_history_nerd 2 ปีที่แล้ว

    the code does work for me but the loading screen stays only for 1 frame such that it isn't really loading unless you pay keen attention which I guess most players won't

    • @kinda_history_nerd
      @kinda_history_nerd 2 ปีที่แล้ว

      does anybody know the solution?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      If the final scene is simple and loads in 1 second the yes the loading scene will only show up for one second.
      If you want to add some kind of pause or wait for player input before loading the final scene then look into Scene Additive Loading.

    • @kinda_history_nerd
      @kinda_history_nerd 2 ปีที่แล้ว

      @@CodeMonkeyUnity I managed to add a timer in the loader callback script. Here's how.
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class LoaderCallback : MonoBehaviour
      {
      bool isFirstUpdate = true;
      float loadingScreenCountdown = 60 * 3;
      void Update()
      {
      if (isFirstUpdate && loadingScreenCountdown == 0)
      {
      isFirstUpdate = false;
      Loader.LoaderCallback();
      }
      else
      {
      loadingScreenCountdown -= 1;
      }
      }
      }

    • @bradbrett
      @bradbrett 2 ปีที่แล้ว

      @@kinda_history_nerd This is not ideal, your timer is frame dependent which means on a faster machine it will count much quicker.

  • @hasanrakib4811
    @hasanrakib4811 5 ปีที่แล้ว +2

    I was wondering how to add a fading effect before the loading screen. Any Idea ? Thanks !

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +2

      You could have a simple Image in the UI stretched to occupy the whole screen then animate the alpha and when it gets to 1 you start actually loading.

  • @JustBitsAndPieces
    @JustBitsAndPieces 4 ปีที่แล้ว

    Hey , i know it's kinda late to ask but i want to make a Boot Scene , how can i change the Loader to acomodate that , do i add the Awake function in the Loader?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      What do you mean by Boot scene? The loader doesnt care what scene is being loaded, it just loads the target scene. That can be your MainMenu, your GameScene or any scene you want.

  • @faiz7180
    @faiz7180 4 ปีที่แล้ว

    I have a question. Why my scene transition is not smooth? There's like a break in between. It will froze for like 1-2 seconds then it changes. Could it be because of my pc? My pc is on the low end btw.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      The Loading scene should be completely empty so it should load almost instantly, if it is already empty then there's not much else you can remove to make it faster.

  • @yuanshi9600
    @yuanshi9600 4 ปีที่แล้ว +1

    4:10 manager

  • @Meraba_Abi
    @Meraba_Abi 5 ปีที่แล้ว

    I dont want to show loading scene every time. as example scene 1 > 2 I want loading scene between, but while 2 > 3 I dont want to show loading scene. How can I do this?

  • @KeiNovak
    @KeiNovak 5 ปีที่แล้ว +1

    I think I saw a feature where they had scenes within a scene. Can you do a sort of tutorial on scenes within a scene and maybe if it's possible to stream it in (example, as you walk closer to a town, it loads the scene with the town models and scripts)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +6

      Additive Scene Loading is something I'd like to cover in the future but first I need to do some research since I've never actually used it.

  • @santerikuusela865
    @santerikuusela865 4 ปีที่แล้ว

    Is there any way I could call those functions on Unity's own Button's OnClick() function?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Sure, you can call the static functions from anywhere

    • @santerikuusela865
      @santerikuusela865 4 ปีที่แล้ว

      @@CodeMonkeyUnity but in the inspector I can't find the function

  • @bassofiahere2155
    @bassofiahere2155 4 ปีที่แล้ว +1

    When I import the package of this video in the scenes "MainMenu" and "GameScene" there is a "Missing prefab". 2019.2.18f1

  • @rekt4759
    @rekt4759 4 ปีที่แล้ว

    Iver been searching for 2 days for this answer: why does my visual studio not have 'using UnityEngine.Scenemanagement' namespace? Ive given up looking.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      the correct name is UnityEngine.SceneManagement;

  • @humournotfound4936
    @humournotfound4936 2 ปีที่แล้ว

    Unity freezes after loading scene 2 and it says "not loaded" in the hierarchy

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      Can you load the scene normally by double clicking it? Any errors in the console?

  • @simonbauer83
    @simonbauer83 3 ปีที่แล้ว +2

    Hey Code Monkey,
    It is a bit since you uploaded the video. However, I really liked your design since it since a static class.
    However, there is a issue with chaining levels and going fourth and back.
    Imagine the chain goes like that: A B C.
    Using your code and expanding on it wasn't difficult.
    The problem is, when I go from B to C, it brings me back to level A not C.
    Digging into it, I saw the problem.
    It executes the Load function but skips over the Action/Callback onLoaderCallback and repeats the previous function (e.g. OnClick) and changes the parameters thus choosing a different level.
    How can this be fixed?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      Use Debug.Log to understand what your code is doing, seems like you have something in your code running in the wrong order

  • @javsjavs8659
    @javsjavs8659 4 ปีที่แล้ว

    In the script Im trying to call the Loader class to, pops an error saying that Loader doesn't exist, even tho Ive made it publica static class. Any help?

    • @javsjavs8659
      @javsjavs8659 4 ปีที่แล้ว

      It turns out I had to have both scripts in the same folder hehe oops

  • @moosegoose1282
    @moosegoose1282 3 ปีที่แล้ว +3

    I dont like this one boss. seems a bit messy

  • @leolivak
    @leolivak 5 ปีที่แล้ว

    In which gameobjects do u put the first two scripts "Loader" and the "GameSceneUI" ?

    • @adakathawa1556
      @adakathawa1556 3 ปีที่แล้ว

      Loader is a static class and you don't put it in any object

  • @TheFurruWasTaken
    @TheFurruWasTaken 3 ปีที่แล้ว

    i keep getting error CS1061, "transform" doesnt have a definition for "find". Please Help.

  • @lablabs3726
    @lablabs3726 5 ปีที่แล้ว

    A tutorial about Additive Scene load Or multi scenes ?
    I want Battle scene to be additive to MainScene. didnt figure out yet how to do that.

  • @marscaleb
    @marscaleb 4 ปีที่แล้ว

    But wait, when do scenes get unloaded?
    I'd like to tell my scenes to load asynchronously and I could draw a loading icon, but if I am always loading through asynch, isn't that going to cause the last level to remain loaded?

    • @theangrycoder4680
      @theangrycoder4680 4 ปีที่แล้ว

      Hi. Maybe this helps: “If LoadSceneMode.Single then all current Scenes will be unloaded before loading” docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html

    • @theangrycoder4680
      @theangrycoder4680 4 ปีที่แล้ว

      There is also: SceneManager.UnloadSceneAsync

  • @niklasb8588
    @niklasb8588 4 ปีที่แล้ว +1

    0:38 lmao

  • @themirlabs
    @themirlabs 5 ปีที่แล้ว

    Ok so what iv dose is quite different i think. I load my lvls and prototypes in from an xml scripyt. so instead iv made a list of actions to callback one at a time updating the loadbar as they complete.
    my question is about the update to make sure a frame update happens. how exactly dose that work? i tried to implement it but im pretty sure iv done it wrong.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      The screen only refreshes when there's an update, so the LoaderCallback script has a Update and only triggers the function that will load the target scene on that first update.
      Its really just the bool isFirstUpdate to test if its the first update and calling the function.

    • @themirlabs
      @themirlabs 5 ปีที่แล้ว

      @@CodeMonkeyUnity ok yeah i figured it out. i didnt force it to run through update. i got it now. thanks

  • @TheBooban
    @TheBooban 4 ปีที่แล้ว

    Ahhh...well it started simple enough

  • @BanksySan
    @BanksySan 5 ปีที่แล้ว +1

    Please don't use a ToString() on an enum, it really unhealthy. Just create a static class with getters for the strings you need (don't use public consts).

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +1

      Why do you say enum.ToString(); is unhealthy and why do you dislike public consts?

    • @oldcat1790
      @oldcat1790 2 ปีที่แล้ว

      Well, for enums ToString is very expensive, GetName is at least two times faster.
      Although it's not very important if we use it once per several minutes, ie for loading scenes.

  • @qqq9542
    @qqq9542 3 ปีที่แล้ว

    Volume needs to be louuuder......

  • @karkal14PL
    @karkal14PL 5 ปีที่แล้ว

    How would i reload the current scene using this Scene Manager?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Just Load the current scene. So in this case if you're in GameScene and you want to reload just call Loader.Load(Scene.GameScene);

  • @EgeDai
    @EgeDai 4 ปีที่แล้ว

    Hi! Thank you very much, the video was very helpful. I was only thinking, I'm switching from one level to another through a bool that returns true when two targets are within the trigger area (a sphere collider). I have the script and the sphere collider under a game object. So I need the trigger to load the loading scene and then load the target scene which should be the initial scene. Is there any way to work with this something like GetActiveScene().buildIndex + 1 perhaps? These level completion zones will be different for different scenes and that's not a problem since I'm not changing the script, I'm just changing the position of the LevelEndZone game object; but for each of my levels, level loaded after the loading scene is fixed atm, as I'm no calling different scenes through different buttons etc... like you are here. I would very much appreciate the help! Thank you!

  • @adakathawa1556
    @adakathawa1556 3 ปีที่แล้ว

    You should null the asyncOperation as well in some point

    • @oldcat1790
      @oldcat1790 2 ปีที่แล้ว

      since it's a local variable of a coroutine, it should become null after the coroutine is ended

  • @DeathGOD7
    @DeathGOD7 5 ปีที่แล้ว

    I think using too much static functions/methods may decrease game performance.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Why do you think that? There's no inherent cost to making a function static.

    • @DeathGOD7
      @DeathGOD7 5 ปีที่แล้ว

      Code Monkey people say it decrease you game performance if used static more

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +3

      I don't know who told you that but it is not true.
      Go ahead and test for yourself, do 1 million iterations of a private void and then a private static void and see how long they take.

    • @DeathGOD7
      @DeathGOD7 5 ปีที่แล้ว

      Haha ok....thank you for this tut.
      Static function can be called from any script right? Mainly used for Singleton and one instance right?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +1

      Yes very useful when you use a singleton pattern since you can access functions and logic in that class without needing to keep a direct reference to it.
      So perfect for any class that you only have one instance of, like Loader, CameraSystem, EnemySpawner, HealthBarUI, etc.

  • @ruqey
    @ruqey 4 ปีที่แล้ว

    You don't mention how to link the buttons

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      What do you mean? You can call the function from anywhere

  • @SherbertKid2011
    @SherbertKid2011 4 ปีที่แล้ว

    I want to add new scene in unity!!!!!!!!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Just right click in your project files and create a new scene

  • @scurcus
    @scurcus 5 ปีที่แล้ว

    me trying to copy what you type without pausing the video

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +2

      It's not a competition so take your time and really learn!

    • @kinda_history_nerd
      @kinda_history_nerd 2 ปีที่แล้ว

      @@CodeMonkeyUnity That's T H E J O K E

  • @just-qw9ge
    @just-qw9ge 5 ปีที่แล้ว

    how to make end Runner game

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว

      Runner is one of the genres I'd like to cover in the future so stay tuned!

  • @watercat1248
    @watercat1248 5 ปีที่แล้ว

    My questions is haw load and muple sean insade other sean with code ?
    I want to have meny difrent seans and to load and unload sencodery seans i want samthin semuler with that Ling code Instead docs.unity3d.com/Manual/MultiSceneEditing.html

    • @arsylgames
      @arsylgames 4 ปีที่แล้ว

      How good is your english do you think?

    • @watercat1248
      @watercat1248 4 ปีที่แล้ว

      @@arsylgames I know I need more practice wean speak English but understand English way you ask ?
      If you don't understand my question I will ask the same questions again

    • @arsylgames
      @arsylgames 4 ปีที่แล้ว

      Water Cat I can understand you but it is hard for me. Is it possible to rewrite it?

    • @watercat1248
      @watercat1248 4 ปีที่แล้ว

      @@arsylgames ok no problem thenx meny time wean comments is hard understand thenks for telling that I will make more clear

    • @watercat1248
      @watercat1248 4 ปีที่แล้ว

      @@arsylgames ok now thing my question more clearly

  • @daniilparokonnyy7980
    @daniilparokonnyy7980 5 ปีที่แล้ว

    Why do you use actions? I can`t really understand what they exactly did.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +1

      The action is just a variable that can hold a function.
      So in this case the function stored in the variable gets executed when the LoaderCallback function is called.

    • @micaiahstevens8840
      @micaiahstevens8840 5 ปีที่แล้ว +2

      Its a holdover for when the code becomes real. Your going to want to respond to things that happen. The actions, stand in for this. Really nicely.
      Now you can write a few things that respond to that action, and not have to have a list of all the functions you need to call.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 ปีที่แล้ว +2

      Yup exactly what @Micaiah Stevens said, it gives you more options to do things when the screen refreshes.
      You could store the target scene in a variable instead of an Action and load that target scene, that would work but would be limited to just loading a scene and nothing else.
      But with an action you could for example write to a log "Started Loading Scene " + scene; or play a sound effect so the player knows the scene is loading or anything you can think of.

  • @yvngxnuxe938
    @yvngxnuxe938 3 ปีที่แล้ว

    Doesn’t even work smh

  • @black_sauce2478
    @black_sauce2478 4 ปีที่แล้ว

    title doesn't match the video content

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      How so? The video is titled Scene Manager and the video deals with making a Scene Manager to manage how you load various scenes.
      What is a Scene Manager to you?

    • @black_sauce2478
      @black_sauce2478 4 ปีที่แล้ว +1

      @@CodeMonkeyUnity Cooooool... I know that haha, I only commented that to get your attention xD. I've been watching your videos since I'm learning unity and it helps a lot!. Thank you so much. I'm also wondering if you have a textbase RPG game tutorial for unity?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      @@black_sauce2478 I've made some Text RPG elements like the Hit Counter and Damage Popups
      th-cam.com/video/IiPTsE1F4PY/w-d-xo.html
      th-cam.com/video/iD1_JczQcFY/w-d-xo.html

    • @black_sauce2478
      @black_sauce2478 4 ปีที่แล้ว

      @@CodeMonkeyUnity Thank you so much

  • @NaniNana881
    @NaniNana881 4 ปีที่แล้ว

    Thank you