Hi I am using EditorGUI as such →
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(Field))]
public class CustomFieldDrawer : PropertyDrawer {
SerializedProperty name;
SerializedProperty prefab;
SerializedProperty usePrefab;
SerializedProperty fieldMesh;
SerializedProperty fieldMaterial;
SerializedProperty scatter;
private int indent;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
name = prop.FindPropertyRelative("FieldName");
prefab = prop.FindPropertyRelative("Prefab");
usePrefab = prop.FindPropertyRelative("usePrefab");
fieldMesh = prop.FindPropertyRelative("FieldMesh");
fieldMaterial = prop.FindPropertyRelative("FieldMaterial");
scatter = prop.FindPropertyRelative("Scatter");
indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUI.PropertyField(pos, prop ,new GUIContent(name.stringValue==""? label.text : name.stringValue));
if(prop.isExpanded)
{
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height,pos.width,pos.height),name );
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height*2,pos.width,pos.height),usePrefab, new GUIContent("Use a Prefab?"));
if(usePrefab.boolValue)
{
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height*3,pos.width,pos.height*2), prefab,new GUIContent("prefab"));
}
else
{
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height*4,pos.width,pos.height*2), fieldMesh);
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height*5,pos.width,pos.height),fieldMaterial);
}
EditorGUI.PropertyField(new Rect(pos.x,pos.y+pos.height*6,pos.width,pos.height), scatter,new GUIContent("Scattering Properties"),true);
}
EditorGUI.indentLevel = indent;
}
}
But it draws it on TOP of the inspector (Picture Below)-
what am I doing wrong? (I should mention that “Field Builder” is a script that initializes an array of serializable type “Field” (the one with my custom PropertyDrawer)
any help is greatly appreciated ![]()