OnGUI loading during call function

Hi
I’ve got a problem, i would like to display a “loading” (with textArea for exemple) during calling a function.

I call a function when i click on a button.

To be more precise :
OnGUI(){
if (GUI.Button(new Rect(20, (_heightMenu / 2) - 10, 80, 20), “Open File”)){
ImportFunction();
}

So, because of ImportFuntion take few times, i want to display “loading” during this calling…

if someone have any idea :slight_smile:

thx

Hey there,

This is built into Unity using the following function.

EditorUtility.DisplayProgressBar(title:"Title", info:"Info", progress:0.5f);

Cheers,

thanks for your reply but i’m coding for an application so i can not use UNITY Editor

Something like this might help:

public Texture progressBackground;
public Texture progressForground;

private void DrawProgress(Vector2 location, Vector2 size, float progress)
{
    GUI.DrawTexture(new Rect(location.x, location.y, size.x, size.y), progressBackground);
    GUI.DrawTexture(new Rect(location.x, location.y, size.x * progress, size.y), progressForground);
}

Plug this into your OnGUI code with appropriate values and you should be on your way.

Does anyone have an idea for creating circle load bars, I mean it is easy with rectangles like @TrickyHandz demonstrated and the new UI system but what for OnGUI.