Search Unity

Lag Before UI Elements Can Be Created/Resized/Moved

Discussion in 'Immediate Mode GUI (IMGUI)' started by twoski, Sep 16, 2014.

  1. twoski

    twoski

    Joined:
    Mar 27, 2014
    Posts:
    27
    So i have been testing a new loading screen. It is a simple canvas with an image element. I instantiate this canvas before loading stuff.

    However, the canvas is not visible until after everything loads despite me instantiating it before calling any of my loading code.

    Do i need to do something hacky like instantiate it when the game loads then move its transform off the screen then move it back when i load? Or is there a way to instantiate it and make it invisible?

    I also have a similar problem with other UI elements. I try to resize/move a canvas after instantiating it but it doesn't work unless i put the resize/move code in an Update function. There is a slight lag before anything i call on a canvas actually registers.

    How do you guys deal with this?
     
  2. twoski

    twoski

    Joined:
    Mar 27, 2014
    Posts:
    27
    Anyone?
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Does your loading code block frame updates? If so, could you run it in a coroutine?
     
  4. twoski

    twoski

    Joined:
    Mar 27, 2014
    Posts:
    27
    It does block frame updates, it would be much nicer if i could just have the loading thing display before i enter the loading code rather than chop it into coroutines.

    How many frame updates need to happen before the loading screen is visible? Couldn't i manually call it or something before entering the loading code?
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You could try a coroutine with one or more "yield return null" statements at the beginning to allow a couple frames to update the UI.