Hi there
I’m trying to create a custom editor UI related to foldout style. Actually it work as expected beside the fact that i have an invisible spacing that is add to my editor window.such as
Not sure how to solve that spacing issue, i tried to substract from the position ligneValue, but it doesn’t change anything
Here’s the code i wrote
public class VariableReferenceEditor : PropertyDrawer
{
SerializedProperty useConstant;
SerializedProperty constantValue;
SerializedProperty variable;
public virtual UnityEngine.Object GetObjectField(SerializedProperty inProperty)
{
return null;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Debug.Log(position.ToString());
EditorGUI.BeginProperty(position, label, property);
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.name);
if(!property.isExpanded)
{
return;
}
EditorGUI.indentLevel++;
useConstant = property.FindPropertyRelative("UseConstant");
constantValue = property.FindPropertyRelative("ConstantValue");
variable = property.FindPropertyRelative("Variable");
useConstant.boolValue = EditorGUILayout.Toggle("Use constant", useConstant.boolValue);
if (useConstant.boolValue)
{
EditorGUILayout.PropertyField(constantValue, new GUIContent("Constant Value"));
}
else
{
variable.objectReferenceValue = GetObjectField(variable);
}
EditorGUI.indentLevel--;
property.serializedObject.ApplyModifiedProperties();
EditorGUI.EndProperty();
EditorUtility.SetDirty(property.serializedObject.targetObject);
}
}
Any advice on that would be helpful
Thanks