Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Problem with .BeginArea & GUILayout going to wrong place

Discussion in 'Extensions & OnGUI' started by StarManta, Jun 1, 2016.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    5,861
    I'm having a weird problem with BeginArea. I have an editor UI with a number of windows (Areas) that can be opened/closed and moved around. I'm using BeginArea extensively to use GUILayout within these windows.

    In the screenshot, you can see the problem near the lower left: the overlapping text label and "Add condition" button should be in the box to the right, not in the parent box they're in.

    Here is the code that draws the box and starts the GUILayout area.
    Code (csharp):
    1.  
    2.         GUI.Box(linkRect, "");
    3.         GUILayout.BeginArea(linkRect);
    4.         GUILayout.Label("Link");
    5.  
    The GUI.Box is being drawn in the correct place, but the layout code started with GUILayout.BeginArea is going to the wrong area. (the "Link" text is the text that's overlapping the other text in the screenshot) I'm having trouble understanding how these two function calls, being called with the same rect literally right next to each other in the code, can be going to two different places. I have confirmed through Debug.Logs that linkRect remains unchanged before and after these lines.

    It should be noted that the layout contents seem to be locked to the parent window - when I drag around the view or the parent window, those contents stay with it. It seems like when it comes time to paint these controls, they are simply being drawn to the wrong "Area", like they're getting mis-linked within UnityGUI's internal code. (When I open link windows on other windows, each one is consistently rendered on top of its own parent window.)

    Has anyone experienced a bug like this before? Am I missing something about the way BeginArea works that makes it different from .Box?
     

    Attached Files:

  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    5,861
  3. Sanctus2099

    Sanctus2099

    Joined:
    Dec 11, 2013
    Posts:
    35
    Am I reading this correctly? Are they marking it as a "Will not fix"? That's a fairly strange way to treat a serious bug.