Created
May 21, 2025 05:49
-
-
Save KaganAyten/79695efc1cff9c3be3c1628e52c931de to your computer and use it in GitHub Desktop.
Creates Dynamic Header On Inspector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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