Skip to content

Instantly share code, notes, and snippets.

@KaganAyten
Created May 21, 2025 05:49
Show Gist options
  • Save KaganAyten/79695efc1cff9c3be3c1628e52c931de to your computer and use it in GitHub Desktop.
Save KaganAyten/79695efc1cff9c3be3c1628e52c931de to your computer and use it in GitHub Desktop.
Creates Dynamic Header On Inspector
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(DynamicHeaderAttribute))]
public class DynamicHeaderDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel)
{
fontSize = 12,
alignment = TextAnchor.MiddleCenter
};
headerStyle.normal.textColor = Color.green;
EditorGUI.LabelField(position, property.stringValue, headerStyle);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUIUtility.singleLineHeight * 1.5f;
}
}
public class DynamicHeaderAttribute : PropertyAttribute
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment