0
\$\begingroup\$

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 ?

\$\endgroup\$
3
  • \$\begingroup\$ what do you do in Loading Scene? \$\endgroup\$ Commented 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\$ Commented Aug 12, 2016 at 3:32
  • \$\begingroup\$ Yes, this could be a good idea. Is that your question? \$\endgroup\$ Commented Aug 12, 2016 at 5:05

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\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\$ Commented Aug 12, 2016 at 7:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.