Unity Loading Screen | Beginner Tutorial (2022)

Sdílet
Vložit
  • čas přidán 8. 09. 2024
  • Learn how to design and implement a loading screen in Unity. Loading your scenes asynchronously can help reduce the time users have to wait between scenes but I'll teach you something that most tutorials don't even mention!
    ➡️Slider Tutorial: • How To Create UI SLIDE...
    ➡️Black Friday Sale: • INSANE Year For Unity ...
    🎁 Get OVER 165+ Scripts, Projects and premium content on my PATREON HERE:
    ➡️bit.ly/SpeedTut...
    ➡️Download the Project here: / 74781420
    ·························································································
    🔥 INSANE UNITY SAVINGS: bit.ly/UnitySa...
    🕹️Unity BLACK FRIDAY SALE: bit.ly/UnitySa...
    🕹️SpeedTutor Unity Store: bit.ly/STUnity...
    🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
    🕹️Unity WELCOME2022 Offer: bit.ly/UnityWe...
    🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleB...
    🕹️Game Art in Blender Tutorial Bundle: bit.ly/GameArt...
    🕹️Low Poly 3D Bundle: speedtutor.net...
    🕹️Unity Tech book Bundle: bit.ly/Program...
    🔥Unity Materials / Files & More:
    🕹️CGAxis PBR Deals: bit.ly/CGAxisP...
    🕹️Synty Assets: bit.ly/SyntyLo...
    🕹️Filebase Assets: filebase.gamed... (Code: SPEEDTUTOR2022 - Sign up for a FREE MONTH)
    🔥 UNITY SUBSCRIPTIONS:
    🕹️Unity Plus: bit.ly/UnityPl...
    🕹️Unity Pro: bit.ly/UnityPr...
    ·························································································
    💰BIG DISCOUNTS on my website, for my UNITY ASSETS:
    ➡️www.speed-tuto...
    💬Join the Community Discord:
    ➡️ / discord
    💝 Make a donation to the channel:
    ➡️www.paypal.me/s...
    ·························································································
    ⬇️ SpeedTutor Puzzle Assets:
    🧩Unity Store: bit.ly/STUnity...
    🧩My Website Discounts: www.speed-tuto...
    ⬇️ SpeedTutor Best Selling Assets:
    🧩Adventure Puzzle Kit: bit.ly/STAdven...
    🧩 Note & Letter System: bit.ly/STNoteL...
    🧩Examine System: bit.ly/STExami...
    🧩Keypad System: bit.ly/STKeypa...
    ⬇️SpeedTutor Model Packs:
    🧩Unity Store: bit.ly/STUnity...
    🧩My Website Discounts: www.speed-tuto...
    My Assets include: Gas Mask, Flashlight, Generator, Themed Key , Padlock, Phone, Chess Puzzle, Lever, Valve Puzzle, Fuse Box & Safe Systems. Cardboard, Debris, Massive Models and more!
    ························································································
    ⭐ Connect with me:
    💬| Discord: / discord
    🐦| Twitter: / speedtutor
    📱 | Facebook: / speedtutoruk
    🖥 | Website: www.speed-tutor...
    ·······················································································
    #SpeedTutor #Unity #LoadingScreen

Komentáře • 57

  • @SpeedTutor
    @SpeedTutor  Před rokem +3

    Slightly late upload today but here we are! Haha. I wanted to create this tutorial to give some good pointers to those who had struggled!
    🔥NEW BLACK FRIDAY SALE!: bit.ly/UnitySalesHub
    🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
    🔥HUMBLE SAVINGS: bit.ly/HumbleBundleDeals

  • @vi6ddarkking
    @vi6ddarkking Před rokem +9

    Interesting Tutorial.
    So Far All My Loading Screens Have Been For "Set Up" After The Scene Loads But Before I Want The Player To Take Control.
    Good To See how It's Made With The Scene.

    • @SpeedTutor
      @SpeedTutor  Před rokem

      Thanks very much for checking this out! :D

  • @CyberStudios
    @CyberStudios Před rokem +6

    Excellent, thank you for this!

  • @gabrielplourde6791
    @gabrielplourde6791 Před rokem +16

    Loading bars: the ultimate lie lol

  • @pilottim136
    @pilottim136 Před měsícem +1

    now i can finally make a loading screen without the game freezing for literal minutes when testing on my old potato pc :D

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

      Haha, I'm glad you can! :D What's the potato specs?

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

      @@SpeedTutor internal graphics, 4GB RAM, 1TB HDD
      Even tho I just made a 2D platformer game (very simple), it literally freezes for a whole minute there while the scene switch

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

      I remember that sort of thing when I was in University! It was a tough time but can you save for another PC?

    • @pilottim136
      @pilottim136 Před měsícem +1

      @@SpeedTutor well, I have a better one for a year now
      (Rtx3060, ram: 16GB, 512GB SSD)
      but I do test my games on a potato PC, just to see if it needs optimisations for low end devices :)
      And I'm pretty new in unity aswell (about 2 or 3 months), so its going good so far :D

    • @SpeedTutor
      @SpeedTutor  Před měsícem +1

      Haha, you're ok then. I don't feel so bad for you at this point :P

  • @user-fx6hs8lv5z
    @user-fx6hs8lv5z Před rokem +5

    my loading screen just flashes by it stays like for 1 second

  • @gmangman123
    @gmangman123 Před rokem +3

    very usefull my game menu! Thx my friend.

    • @SpeedTutor
      @SpeedTutor  Před rokem +1

      You're very welcome, thanks for watching! :)

  • @mrunalumate5399
    @mrunalumate5399 Před 2 měsíci +1

    thnks brother

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

    so there's no way to fix in editor?

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

      I'm not sure about that one, as the editor does things slightly differently.

  • @hnentertainmentslk
    @hnentertainmentslk Před rokem +3

    Nice

    • @SpeedTutor
      @SpeedTutor  Před rokem +1

      Thanks for checking this out! :D

  • @1984ordep
    @1984ordep Před rokem +3

    Im wondering if you might help me. Im learning and I have created a level select in my game like super Mario world. SO the character moves around the map and when it lands on a level square you hit space and the level load. Being that I'm not using BUTTONS how would I trigger the load screen with the example you showed here. Hope you can help me understand a bit more. THANK YOU

    • @SpeedTutor
      @SpeedTutor  Před rokem +1

      Hey there, you can take the exact code that activates on a button press and just do the same on a trigger event. Like "OnTriggerEnter". Does that make sense?

    • @1984ordep
      @1984ordep Před rokem +1

      @@SpeedTutor that makes sense... Im trying to implement it into my own script. The map points are the locations on the map that my character moves to and if that's a LEVEL and I beat the one level before that one then it lets me press a button and the level loads. You gonna notice some things like gems and stuff which are just little icons that populate over the level graphic.....I get the idea of using an OTriggerEnter2D but im not quite sure where in the code to do it I keep playing with it and I keep getting error. Would love your input.. Here is my map code
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class MapPoint : MonoBehaviour
      {
      public MapPoint up, right, down, left;
      public bool isLevel, isLocked;
      public string levelToLoad, levelToCheck, levelName;
      public int gemsCollected, totalGems;
      public int BigCoinCollected, totalBigCoin;
      public float bestTime, targetTime;
      public GameObject gemBadge, timeBadge, BigCoinBadge;
      // Start is called before the first frame update
      void Start()
      {
      if(isLevel && levelToLoad !=null)
      {
      if(PlayerPrefs.HasKey(levelToLoad + "_gems"))
      {
      gemsCollected = PlayerPrefs.GetInt(levelToLoad + "_gems");
      }
      if (PlayerPrefs.HasKey(levelToLoad + "_BigCoin"))
      {
      BigCoinCollected = PlayerPrefs.GetInt(levelToLoad + "_BigCoin");
      }
      if (PlayerPrefs.HasKey(levelToLoad + "_time"))
      {
      bestTime = PlayerPrefs.GetFloat(levelToLoad + "_time");
      }
      if(gemsCollected >= totalGems)
      {
      gemBadge.SetActive(true);
      }
      if (BigCoinCollected >= totalBigCoin)
      {
      BigCoinBadge.SetActive(true);
      }
      if (bestTime

    • @1984ordep
      @1984ordep Před rokem +1

      @@SpeedTutor I also have another code that controls all the map points which is this one...
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class LSManager : MonoBehaviour
      {
      public LSPlayer thePlayer;
      private MapPoint[] allPoints;
      // Start is called before the first frame update
      void Start()
      {
      allPoints = FindObjectsOfType();
      if(PlayerPrefs.HasKey("CurrentLevel"))
      {
      foreach(MapPoint point in allPoints)
      {
      if(point.levelToLoad == PlayerPrefs.GetString("CurrentLevel"))
      {
      thePlayer.transform.position = point.transform.position;
      thePlayer.currentPoint = point;
      }
      }
      }
      }
      // Update is called once per frame
      void Update()
      {
      }
      public void LoadLevel()
      {
      StartCoroutine(LoadLevelCo());
      }
      public IEnumerator LoadLevelCo()
      {
      AudioManager.instance.PlaySFX(4);
      LSUIController.instance.FadeToBlack();
      yield return new WaitForSeconds((1f / LSUIController.instance.fadeSpeed) + .25f);
      SceneManager.LoadScene(thePlayer.currentPoint.levelToLoad);
      }
      }

  • @alejandro60251
    @alejandro60251 Před 10 měsíci +2

    Amazing tutorial mate, I have just one question. When I implemented the loading bar into my game it goes from 0 to 34%, and then goes back to 22% and then freezes there and finally goes all the way to a 100% when the game is about to load. Is there anything you know I can do about it?

    • @SpeedTutor
      @SpeedTutor  Před 10 měsíci

      That's a tough question, I'm not sure I can give you a good answer other than trying to do some searching online. Sorry about that .

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

      I think you messed up the bar it self I think sorry I just started a minute ago

  • @juniorski487
    @juniorski487 Před rokem +2

    my loading screen just flashes by it stays like for 1 second and how to fix this like i want more longer 4-5 sec max

  • @SunSailor
    @SunSailor Před rokem +5

    And yet - the best loading screen is always the one, you don't need. Let's face it, bulk loading is always some kind of laziness. Not always avoidable, because setting up streaming is more work and needs more robust systems, but at the end, it is always technically possible. Simply look at lands of lore on the C64, which already streamed a whole open world on a 1Mhz machine with 64KB RAM and an ultra slow disk drive with 170KB. Eventually, we moved away from scenes anyway and use addressables instead, which give a much more grained control on loaded and unloaded assets.

    • @SpeedTutor
      @SpeedTutor  Před rokem +2

      I can agree on that but sometimes to ship a perfectly functional game, this isn't always or even possible as you mention. More ingrained systems come with experience, especially when you have so many other facets to deal with. Thanks for your comment though! :)

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

    Hi the loading is awesome works fine but is there anyway to slow down the loading to at least like a minimum of 5secs cause the loading flashes before my eyes that I don't need the loading anymore. Anyways I'm working in a 2d game of course its lightweight anyways I run the the game in built version.

    • @SpeedTutor
      @SpeedTutor  Před 3 měsíci +1

      That's a tough question as it's super light weight but you could create a co-routine to wait a number of seconds after the a sync operation has completed, you know it's done loading but you just wait for your allotted time before activating. I'm not sure if it's the best way but a suggestion.

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

      @@SpeedTutor Thanks for the suggestion. but I did something else, Idk if this the best way to go but I was so desperate to have a long loading screen (Since its a intro loading of the game) I just animate the whole loading screen and throw a coroutine, after that coroutine is done the main menu scene loads. I know its a pretty bad idea, but it works for me. I guess.....

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

      Sometimes the thing that works doesn't have to be the very best, your loading in fast anyway. So I'm glad you've got it sorted :)

  • @RHYSHALLDIGITALART00122
    @RHYSHALLDIGITALART00122 Před 9 měsíci

    will this work with photon 2.
    this is by far the hardest thing ive added to my game and im not an amatuer.
    however its multiplayer so networking may be an issue.

    • @SpeedTutor
      @SpeedTutor  Před 9 měsíci

      I'm really not sure about that one, I'm not experienced with multiplayer at all but I imagine it should work.

  • @debmarkproductions
    @debmarkproductions Před 6 měsíci

    I was wondering if your routine will work with the initial loading of the game itself that takes 5 minutes before starting, or is it just for loading other levels while the game is running. If it doesn't work for game loading, do you have any information on how to do that? Thanks.

    • @SpeedTutor
      @SpeedTutor  Před 6 měsíci

      I imagine it should work for something like that, but 5 minutes a pretty long time. What's the project? If you don't me asking.

    • @debmarkproductions
      @debmarkproductions Před 6 měsíci +1

      I am about 2/3 done with level 1, of probably 5, of "The Tower of Destiny" and it already takes up 7.5 GB. It is a semi-realistic Christian adventure game where the player goes through a wilderness on a path coming across various buildings where he meets different characters. He has to determine if they are telling him the truth or trying to deceive him. At some of the houses he is fed with spiritual food (Bible verses) that act as weapons against deceiving demons to dispel them. He must use the correct verse to counter what the demon tells him or he will be injured himself. The purpose of the game is to teach what salvation is all about, to help memorize Bible verses, and to help respond to those who ask for a reason for the hope that Christians have (otherwise known as apologetics). The target audience is anyone over 6 yrs old.

    • @SpeedTutor
      @SpeedTutor  Před 6 měsíci

      I think that's a very honourable creation but what makes the game take 5 minutes to load? It's something that won't go down with players, as they hate waiting. Haha.

  • @alaxi-ball2453
    @alaxi-ball2453 Před 7 měsíci

    where do you get the background to load the game?

    • @SpeedTutor
      @SpeedTutor  Před 7 měsíci

      Could you explain a little more for me?

    • @alaxi-ball2453
      @alaxi-ball2453 Před 7 měsíci

      @@SpeedTutor I mean, where do you get the background of the loading screen?

    • @SpeedTutor
      @SpeedTutor  Před 7 měsíci

      Oh it's just a screenshot of one of the games I was making :)

  • @khajanawaz4136
    @khajanawaz4136 Před rokem

    Can we remove unity loading screen in webgl can you make a video on this

    • @SpeedTutor
      @SpeedTutor  Před rokem

      You mean the Unity splash screen that automatically appears? If that's what you mean, sadly not unless you subscribe to Unity Plus or Pro. I think plus is the lowest version you'd need to get rid of it.

    • @khajanawaz4136
      @khajanawaz4136 Před rokem

      @@SpeedTutor i mean after splash screen comes loading screen i want to remove that loading screen from webgl

    • @SpeedTutor
      @SpeedTutor  Před rokem

      I don't think you can get rid of that one but I'm not 100% sure about that!

  • @marcus_vdm
    @marcus_vdm Před rokem +2

    I actually have a slight 'issue' with loading in my game. Perhaps you can help. I have an extra step nested in the while loop. This is the 'press to continue' code block (as I have a little story showing on my loading screen). Everything works as it should, but the thing is my loading bar is acting not as expected. It loads to about 6% normally, but then it stops showing the progression (percentage wise, the actual game is indeed still loading, but the player might think the game froze up), after a minute or so, it shoots up to 95/ 100 % and the press to continue can be done with space bar. I was hoping to see a somewhat more gradual loading progression from 0 to 100 with maybe some chunks loaded faster here and there. This is the code I'm using
    public class LevelLoader : MonoBehaviour
    {
    [SerializeField] private int sceneToLoad;
    [SerializeField] private Slider loadingBar;
    [SerializeField] private TextMeshProUGUI percentageText;
    [SerializeField] private GameObject loadingIcon;
    [SerializeField] private TextMeshProUGUI pressContinue;
    private void Start()
    {
    pressContinue.enabled = false;
    loadingIcon.SetActive(false);
    LoadScene(sceneToLoad);
    }
    public void LoadScene(int sceneIndex)
    {
    StartCoroutine(LoadAsynchronously(sceneIndex));
    }
    IEnumerator LoadAsynchronously(int sceneIndex)
    {
    AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
    loadingIcon.SetActive(true);
    operation.allowSceneActivation = false;
    while (!operation.isDone)
    {
    float progress = Mathf.Clamp01(operation.progress / .9f);
    loadingBar.value = progress;
    percentageText.text = (progress * 100f).ToString("F0") + " %";

    if (operation.progress >= .9f && !operation.allowSceneActivation)
    {
    loadingIcon.SetActive(false);
    pressContinue.enabled = true;
    if (Input.GetKeyDown(KeyCode.Space))
    {
    operation.allowSceneActivation = true;
    }
    }
    yield return null;
    }
    }
    }
    Is there something I can improve on?

    • @SpeedTutor
      @SpeedTutor  Před rokem

      Are you having this issue directly in the editor or within a build too?

    • @marcus_vdm
      @marcus_vdm Před rokem +1

      @@SpeedTutor As far as I know the only way to test the loading bar properly is in build. In the editor there are no errors in the console, that makes it so tricky to see the problem. If there is even a problem since everything works as it should. It's just the 'freezing' of the loading bar that may throw players off, thinking the game froze while this isn't the case. The level loads fine after a minute or so on my HDD. (I couldn't test it on SSD since it loads so fast the bar goes from 0 to 100 in 1 sec :😜). I'm trying to understand what (and how) Unity loads in the background while it's loading asynchronously.. seems in my level it's the first chunk of data then it has a hard time reflecting the rest of it. I really should test this with another scene...

  • @AvstractIndustries
    @AvstractIndustries Před rokem +2

    Tomorrow is Monday 😁

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

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using UnityEngine.SceneManagement;
    public class startScene : MonoBehaviour
    {
    public Slider loadingSlider;
    public string sceneName;
    public GameObject startButton;
    bool loading;
    AsyncOperation asyncOp;
    public void startGame()
    {
    loadingSlider.gameObject.SetActive(true);
    asyncOp = SceneManager.LoadSceneAsync(sceneName);
    loading = true;
    startButton.SetActive(false);
    }
    void Update()
    {
    if(loading == true)
    {
    loadingSlider.value = asyncOp.progress;
    if(asyncOp.progress >= 0.99f)
    {
    asyncOp.allowSceneActivation = true;
    }
    }
    }
    }