Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom inspector: label overlapped when unityEvent box pops up

Discussion in 'Immediate Mode GUI (IMGUI)' started by BubyMB, Jan 23, 2018.

  1. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    Full Inspector code: https://gist.github.com/Bubytech/e1027f84b7ca210fababb06ddfd40ed6
    Hey guys running into a weird problem;
    Code (csharp):
    1. if (piechart.TriggerOnClick)
    2. {
    3. SerializedProperty clickMethod = serializedObject.FindProperty("clickMethod");
    4. EditorGUIUtility.labelWidth = 25;
    5. EditorGUIUtility.fieldWidth = 50;
    6. EditorGUILayout.PropertyField(clickMethod);
    7. }
    It's pretty simple, but when TriggerOnClick is true it shows a UnityEvent box where you can put your function in etc, but when I do that
    Code (csharp):
    1. for (int i = 0; i < piechart.dataList.Count; i++)
    2. {
    3. GUILayout.BeginHorizontal();
    4. GUILayout.BeginVertical();
    5.  
    6. piechart.dataList[i].name = EditorGUILayout.TextField("Name:", piechart.dataList[i].name);
    7.  
    8. GUILayout.BeginHorizontal();
    9. piechart.dataList[i].value = EditorGUILayout.FloatField("Value:", piechart.dataList[i].value);
    10. EditorGUILayout.LabelField("By Percentage: %" + ((piechart.dataList[i].value / piechart.overallValue) * 100).ToString("F2"));
    11. GUILayout.EndHorizontal();
    12.  
    13. piechart.dataList[i].color = EditorGUILayout.ColorField("Color:", piechart.dataList[i].color);
    14.  
    15. if (GUILayout.Button("Remove"))
    16. piechart.dataList.Remove(piechart.dataList[i]);
    17.  
    18. GUILayout.EndVertical();
    19. GUILayout.EndHorizontal();
    20.  
    21. GUILayout.Space(10);
    22. this.Repaint();
    23. }
    this gets affected which is just an input area.