1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| [CanEditMultipleObjects] [CustomEditor(typeof(CustomMonoBehaviour),true)] public class CustomEditor : Editor{ public Texture2D icon; public GUIStyle fontStyle; private void OnEnable() { icon = Resources.Load("") as Texture2D; }
public override void OnInspectorGUI() { CheckEditorProperties(); serializedObject.Update(); GUILayout.BeginVertical(); DrawTittleHeader(); DrawGUI(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
protected virtual void DrawTittleHeader() { GUILayout.BeginHorizontal(); if (icon) GUILayout.Label(icon, GUIStyle.none, GUILayout.Height(70), GUILayout.Width(70)); GUILayout.Box("", fontStyle); GUILayout.EndHorizontal(); } protected virtual void CheckEditorProperties() { if (fontStyle == null) { fontStyle = new GUIStyle(EditorStyles.whiteLargeLabel); fontStyle.imagePosition = ImagePosition.ImageLeft; fontStyle.alignment = TextAnchor.UpperLeft; fontStyle.fontSize = 23; fontStyle.fontStyle = FontStyle.Bold; fontStyle.wordWrap = true; fontStyle.clipping = TextClipping.Clip; }} }
|