Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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,283
    Maybe post some code, hard to tell what's going on here.