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
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 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 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
I am loading a very large scene, usually takes approx 30 seconds to load. When I debug this, the progress jumps from 0 to 1 instantly, no loading bar fill change whatsoever. What gives?
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?
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
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?
@@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
@@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); } }
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.
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! :)
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.
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.
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.
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.
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.
@@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.....
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.
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.
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 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...
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
It didn’t work in unity 6 so can you make the tutorial for unity 6
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.
Thanks very much for checking this out! :D
Excellent, thank you for this!
You're very welcome! :D
Loading bars: the ultimate lie lol
Haha, tell me about it! :P
my loading screen just flashes by it stays like for 1 second
now i can finally make a loading screen without the game freezing for literal minutes when testing on my old potato pc :D
Haha, I'm glad you can! :D What's the potato specs?
@@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
I remember that sort of thing when I was in University! It was a tough time but can you save for another PC?
@@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
Haha, you're ok then. I don't feel so bad for you at this point :P
so there's no way to fix in editor?
I'm not sure about that one, as the editor does things slightly differently.
very usefull my game menu! Thx my friend.
You're very welcome, thanks for watching! :)
Thanks for Tutorial
No problem at all, thanks for watching! :D
I am loading a very large scene, usually takes approx 30 seconds to load. When I debug this, the progress jumps from 0 to 1 instantly, no loading bar fill change whatsoever. What gives?
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?
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 .
I think you messed up the bar it self I think sorry I just started a minute ago
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
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?
@@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
@@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);
}
}
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.
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! :)
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.
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.
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.
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.
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
How big of a scene are you loading?
thnks brother
You're very welcome!
where do you get the background to load the game?
Could you explain a little more for me?
@@SpeedTutor I mean, where do you get the background of the loading screen?
Oh it's just a screenshot of one of the games I was making :)
Nice
Thanks for checking this out! :D
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.
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.
@@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.....
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 :)
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.
I'm really not sure about that one, I'm not experienced with multiplayer at all but I imagine it should work.
Can we remove unity loading screen in webgl can you make a video on this
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.
@@SpeedTutor i mean after splash screen comes loading screen i want to remove that loading screen from webgl
I don't think you can get rid of that one but I'm not 100% sure about that!
Tomorrow is Monday 😁
You're exactly right! :D
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?
Are you having this issue directly in the editor or within a build too?
@@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...
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;
}
}
}
}