Search Unity

EditorGUILayout.ObjectField + Width Vs height

Discussion in 'Immediate Mode GUI (IMGUI)' started by Chaosgod_Esper, Feb 8, 2017.

  1. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    Hi there..

    I´m working on a Mapeditor Extention for Isometric Tiles. But i currently stuck at the ObjectField of the EditorGui (cosmetic problem)
    here´s an Example:


    Left is a Texture2D Field, which i can Resize to my desired Width and Height (Width/2).
    Now, i need to create Object Fields to make Users beeing able to Drag&Drop Spriteobjects into the System.

    This is the Current approach to create the ObjectField:
    Code (csharp):
    1.  
    2. private GUILayoutOption[] Quad = new GUILayoutOption[]{GUILayout.MaxWidth(64), GUILayout.MaxHeight(32), GUILayout.Width(64), GUILayout.Height(32)};
    3.  
    4. [...]
    5.  
    6. SpriteObject = (Sprite)EditorGUILayout.ObjectField("Centerpiece (Thumb):", SpriteObject , typeof(Sprite), Quad); // new GUILayoutOption[]{GUILayout.MaxWidth(64), GUILayout.MaxHeight(32), GUILayout.Width(64), GUILayout.Height(32)});
    7.  
    But it only draws the ObjectField as a Square Field..instead of a Height = Width/2 Rectangle..

    Is there an Option to get my desired Field?


    Fixed by setting GUI.Content to none and overwriting GUILayout without MaxHeight/Width
     
    Last edited: Mar 3, 2017
  2. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    Since ther´s no answer here.. i fixed the StartPost problem.. and got TWO new ones..

    Current Shot:


    Problem 1:
    The Scrollview of this Windows has a white background textur. Same for BeginHorizontal and BeginVertical.
    BUT, whenever i put a Sprite with transparent Background inside an ObjectField, the White background of the Areas get overwirtten, and it ends up in rendering the Transparent grid..

    Problem 2:
    Is there a way to hide this "select" Labelbox of an ObjectField?


    Hope for some answers this time, since this problems annoy me for around 2 Weeks now :(
     
  3. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Maybe post some code, hard to tell what's going on here.