Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnGUI loading during call function

Discussion in 'Immediate Mode GUI (IMGUI)' started by m.marc, Jun 6, 2016.

  1. m.marc

    m.marc

    Joined:
    Mar 23, 2016
    Posts:
    5
    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 :)

    thx
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey there,

    This is built into Unity using the following function.
    Code (CSharp):
    1. EditorUtility.DisplayProgressBar(title:"Title", info:"Info", progress:0.5f);
    Cheers,
     
  3. m.marc

    m.marc

    Joined:
    Mar 23, 2016
    Posts:
    5
    thanks for your reply but i'm coding for an application so i can not use UNITY Editor
     
  4. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    Something like this might help:
    Code (csharp):
    1.  
    2. public Texture progressBackground;
    3. public Texture progressForground;
    4.  
    5. private void DrawProgress(Vector2 location, Vector2 size, float progress)
    6. {
    7.     GUI.DrawTexture(new Rect(location.x, location.y, size.x, size.y), progressBackground);
    8.     GUI.DrawTexture(new Rect(location.x, location.y, size.x * progress, size.y), progressForground);
    9. }
    10.  
    Plug this into your OnGUI code with appropriate values and you should be on your way.
     
  5. Rad-Coders

    Rad-Coders

    Joined:
    Apr 10, 2015
    Posts:
    36
    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.