Search Unity

How to exclude Header attribute inside unity custom editor EditorGUILayout.PropertyField

Discussion in 'Scripting' started by innoveam, Jun 27, 2021.

  1. innoveam

    innoveam

    Joined:
    Feb 5, 2016
    Posts:
    2
    Im trying to make a custom unity editor and stumbled upon a problem for hours. I have this problem when i tried to use EditorGUILayout.PropertyField on the editor script. I cant use other editor field too because my editor tool needs to dynamically draw everything just like on the inspector. i also tried to include my custom property that has has custom PropertyDrawer.

    upload_2021-6-28_2-46-45.png

    here's the code i used in the editor:

    Code (CSharp):
    1. SerializedObject so = new SerializedObject(entry.target);
    2.  
    3. so.Update();
    4. SerializedProperty prop = so.FindProperty(entry.memberName);
    5.  
    6. if (prop != null)
    7.    EditorGUILayout.PropertyField(prop, GUIContent.none);
    8.  
    9. so.ApplyModifiedProperties();
    and here are the implementations, I use custom property drawer for the Optional<> :

    Code (CSharp):
    1. [Header("Targets")]
    2. public Transform targetContainer;
    3.  
    4. [Header("Position")]
    5. public Optional<AttachMode> attachPosition = new Optional<AttachMode>(AttachMode.Relative, true);
    Is there any way not to include the [Header] attribute inside the EditorGUILayout.PropertyField?
     
  2. innoveam

    innoveam

    Joined:
    Feb 5, 2016
    Posts:
    2