I’m trying to align fields horizontaly in a custom drawer but I get this error:
ArgumentException: GUILayout:
Mismatched LayoutGroup.Repaint
UnityEngine.GUILayoutUtility.BeginLayoutGroup
(UnityEngine.GUIStyle style,
UnityEngine.GUILayoutOption options,
System.Type LayoutType) (at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/GUILayoutUtility.cs:210)
UnityEditor.EditorGUILayout.BeginHorizontal
(UnityEngine.GUIContent content,
UnityEngine.GUIStyle style,
UnityEngine.GUILayoutOption options)
(at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/EditorGUI.cs:5854)
UnityEditor.EditorGUILayout.BeginHorizontal
(UnityEngine.GUILayoutOption
options) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/EditorGUI.cs:5833)
LevelInfoEditor.OnGUI (Rect position,
UnityEditor.SerializedProperty
property, UnityEngine.GUIContent
label) (at
Assets/Scripts/Editor/LevelInfoEditor.cs:22)
UnityEditor.PropertyDrawer.OnGUISafe
(Rect position,
UnityEditor.SerializedProperty
property, UnityEngine.GUIContent
label) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23)
UnityEditor.PropertyHandler.OnGUI
(Rect position,
UnityEditor.SerializedProperty
property, UnityEngine.GUIContent
label, Boolean includeChildren) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:134)
UnityEditor.EditorGUI.PropertyFieldInternal
(Rect position,
UnityEditor.SerializedProperty
property, UnityEngine.GUIContent
label, Boolean includeChildren) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/EditorGUI.cs:4363)
UnityEditor.EditorGUI.PropertyField
(Rect position,
UnityEditor.SerializedProperty
property, Boolean includeChildren) (at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/EditorGUIBindings.cs:698)
UnityEditor.EditorGUI.PropertyField
(Rect position,
UnityEditor.SerializedProperty
property) (at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/EditorGUIBindings.cs:693)
UnityEditor.Editor.OptimizedInspectorGUIImplementation
(Rect contentRect) (at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/EditorBindings.cs:202)
UnityEditor.GenericInspector.OnOptimizedInspectorGUI
(Rect contentRect) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/GenericInspector.cs:46)
UnityEditor.InspectorWindow.DrawEditor
(UnityEditor.Editor editor, Int32
editorIndex, Boolean forceDirty,
System.Boolean&
showImportedObjectBarNext,
UnityEngine.Rect&
importedObjectBarRect, Boolean
eyeDropperDirty) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1069)
UnityEditor.InspectorWindow.DrawEditors
(UnityEditor.Editor editors) (at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:903)
UnityEditor.InspectorWindow.OnGUI ()
(at
C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:332)
System.Reflection.MonoMethod.Invoke
(System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder
binder, System.Object parameters,
System.Globalization.CultureInfo
culture) (at
/Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
My class:
[CustomPropertyDrawer(typeof(SpawnInfo))]
public class LevelInfoEditor : PropertyDrawer
{
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
{
//base.OnGUI(position, property, label);
EditorGUILayout.BeginHorizontal(); // error!
EditorGUILayout.EndHorizontal();
}
}