I have a quastion about loading screen in unity. I don't want to make a scene between to levels [Main Menu > Loading Scene > Game level]. I want to use Canvas "Image"that run at the start of the game level and then disappear after few seconds [Main Menu > Game level]. Is this good idea ?
-
\$\begingroup\$ what do you do in Loading Scene? \$\endgroup\$Sourav Paul Roman– Sourav Paul Roman08/12/2016 03:18:55Commented Aug 12, 2016 at 3:18
-
\$\begingroup\$ A Loading screen or scene is a scene use to give time for game level to be loaded. [gamasutra.com/blogs/SarahHerzog/20151125/260053/… \$\endgroup\$user43474– user4347408/12/2016 03:32:07Commented Aug 12, 2016 at 3:32
-
\$\begingroup\$ Yes, this could be a good idea. Is that your question? \$\endgroup\$Kromster– Kromster08/12/2016 05:05:31Commented Aug 12, 2016 at 5:05
1 Answer
If I understand correctly, you just want a Main Menu canvas to exist in your level and disable/destroy it when you're done with it. So just do exactly that in the OnClick handler of your button(s).
public void OnClick()
{
gameObject.SetActive(false);
}
Have the above in a script attached to your menu canvas' object and select it as the method to call for your button's OnClick.
Now, if you want this to happen automatically after, say, 5 seconds...
float delay = 5f;
float timer = 0f;
private void Update()
{
timer += Time.deltaTime;
if (timer >= delay)
{
gameObject.SetActive(false);
}
}
There are much better and more concise ways to handle delayed actions like this, but this should demonstrate things adequately.
-
\$\begingroup\$ Probably the most simple way you will find to do it, i actually like this method allot. +1 for you! I was trying to think of the most complex way, that actually causes objects to load in stages to allow for everything to load properly, but this works way better haha. \$\endgroup\$Ryan white– Ryan white08/12/2016 07:51:09Commented Aug 12, 2016 at 7:51