How to make sure that an element visually appears before the rest of the code instructions?

Hello everyone, I have a little issue here.

  • I want to allow the app user to choose between two modes. When choosing a particular mode, I want the interface to temporarily disappear while the other mode is loaded, and within that short time, I want to display a “Loading…” message. This way, I want the user they know that the app is loading the new mode, so that they don’t press the button twice and cancel what they have just asked for.

I have tried this:

Texte_Target.text= “Loading…”;

Btn_SwitchMode_Target.SetActive(false);

The problem is that the next part of the program loads before that part is realized. That is to say that the next mode is activated, with the interface, the camera and all, before the message “Loading…” and the disappearing interface occurs. In terms of programming it seems to work, but too late, and visually, it does not work.So basically the button is “programmatically” deactivated, but visually it is still there.

This leads to a simple question: is there a means to make sure that an object is truly deactivated visually or that a text is truly displayed before going on with the next part of the program?

I might add that I have also tried with the WaitForEndofFrame corutine, but in addition to the fact that I’m really not familiar with that function, it didn’t work.

Thank you for your attention =)

There are different ways of doing it. If this is a popup, you have this popup, then you do an invoke call to a method that then loads your mode after a set amount of seconds. This way you just let the loading sit up for a few seconds.

You could do a coroutine that displays your loading stuff, does a yield return (or a while loop if you want to do a visual update also) and then once that finishes, it closes out your loading.

You can do a scene that is designed to just display loading.

Basic idea is you create your own delay.

thank you very much :slight_smile: