Search Unity

Having trouble styling custom UI

Discussion in 'Immediate Mode GUI (IMGUI)' started by Jason_lIlxe, May 29, 2020.

  1. Jason_lIlxe

    Jason_lIlxe

    Joined:
    Apr 6, 2019
    Posts:
    1
    I want to make a two-column UI in unity to manage a pair of fields so I made a custom UI. Howerver, I came up with this inconvenient view and can't help myself. This is what it looks like.



    My trouble is: I can't remove the "Element" tag. Is there a way to remove them?
    Besides, I'd like to know how to add a little space between these two columns.

    This is my code in my custom editor(I did't use property drawer for it didn't seem to work):
    Code (CSharp):
    1.  
    2. public override void OnInspectorGUI()
    3.         {
    4.             serializedObject.Update();
    5.             EditorGUILayout.PropertyField(_itemNumber);
    6.             _itemNumberToShow = _itemNumber.intValue;
    7.             GUILayout.BeginHorizontal();
    8.             GUILayout.BeginVertical();
    9.             GUILayout.Label("Item Name");
    10.             for (int i=0; i<_itemNumberToShow; i++)
    11.             {
    12.                 SerializedProperty itemProperty = _items.GetArrayElementAtIndex(i);
    13.                 EditorGUILayout.PropertyField(itemProperty);
    14.             }
    15.             GUILayout.EndVertical();
    16.             GUILayout.BeginVertical();
    17.             GUILayout.Label("Drop Chance");
    18.             for(int i=0; i<_itemNumberToShow; i++)
    19.             {
    20.                 SerializedProperty chanceProperty = _chances.GetArrayElementAtIndex(i);
    21.                 if (chanceProperty.floatValue < 0)
    22.                     chanceProperty.floatValue = 0;
    23.                 EditorGUILayout.PropertyField(chanceProperty);
    24.             }
    25.             GUILayout.EndVertical();
    26.             GUILayout.EndHorizontal();
    27.             if (_itemNumber.intValue < 0)
    28.                 _itemNumber.intValue = 0;
    29.             serializedObject.ApplyModifiedProperties();
    30.         }
    31.  
    Thank you for reading!
     

    Attached Files: