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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question Object picker broken for third column on horizontal layout

Discussion in 'Immediate Mode GUI (IMGUI)' started by bboydaisuke, Oct 23, 2022.

  1. bboydaisuke

    bboydaisuke

    Joined:
    Jun 14, 2014
    Posts:
    67
    Hello,

    I'm trying layout list editor horizontally like this:


    However, object picker is not working for third or later columns:


    How can I solve the problem? Any comment will be appreciated.

    <notes>
    1. Wider or thinner width didn't solve
    2. Problem appears if third or later column is Array or List of object
    3. If this problem couldn't be solved, I might want to make tools csv -> ScriptableObject converter

    <code>
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class Example : EditorWindow
    5. {
    6.     // settings
    7.     [SerializeField] AnimationClip[] _a;
    8.     [SerializeField] GameObject[] _b;
    9.     [SerializeField] AnimationClip[] _c;
    10.     [SerializeField] AudioClip[] _d;
    11.     float _width = 180f;
    12.     float _height = 20f;
    13.  
    14.     [MenuItem("Example/Example")]
    15.     static void Init()
    16.     {
    17.         var window = GetWindow<Example>("Window");
    18.     }
    19.  
    20.     private void OnGUI()
    21.     {
    22.         var so = new SerializedObject(this);
    23.         so.Update();
    24.         // layout horizontally
    25.         EditorGUILayout.BeginHorizontal(GUI.skin.box);
    26.         EditorGUILayout.PropertyField(so.FindProperty("_a"), true,
    27.             GUILayout.Width(_width), GUILayout.Height(_height));
    28.         EditorGUILayout.PropertyField(so.FindProperty("_b"), true,
    29.             GUILayout.Width(_width), GUILayout.Height(_height));
    30.         EditorGUILayout.PropertyField(so.FindProperty("_c"), true,
    31.             GUILayout.Width(_width), GUILayout.Height(_height));
    32.         EditorGUILayout.PropertyField(so.FindProperty("_d"), true,
    33.             GUILayout.Width(_width), GUILayout.Height(_height));
    34.         EditorGUILayout.EndHorizontal();
    35.         so.ApplyModifiedProperties();
    36.     }
    37. }
    38.  
     
    Last edited: Oct 24, 2022