Hi,
I’m getting this error:
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:5847)
UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/EditorGUI.cs:5826)
UnityEditor.InspectorWindow.AddComponentButton (UnityEditor.Editor[] editors) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1208)
UnityEditor.InspectorWindow.OnGUI () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:359)
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)
While using this code:
[CustomPropertyDrawer(typeof(Test))]
class TestDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout)
{
GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
base.OnGUI(position, property, label);
}
}
}
And it doesn’t draw out properly, it just glitches the whole inspector.
I tried switching out the GUILayout.Box for GUI.skin.box.draw and got it to work, but it didn’t maintain the layout like I intend it to do.
I’ve been stuck on this for a couple hours, attempting to Google/search the Forum/Answers for a fix, but I couldn’t find one. All the answers that I found didn’t work for me.
Does anyone know of a fix for this? If so, how do I fix it?
Thank you,
KaliTech.
EDIT: I found a temporary fix(which I dislike, so I still need help) by increasing the position manually. It’s unreliable for my situation, but it works for now I guess.
Thanks.
EDIT: Here’s what I’m left with after Bunny83’s suggestion:
And with this code:
[CustomPropertyDrawer(typeof(Test))]
class TestDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
EditorGUILayout.Space();
base.OnGUI(position, property, label);
}
}
