forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomHeaderDrawer.cs
43 lines (37 loc) · 1.14 KB
/
CustomHeaderDrawer.cs
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
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace HoloToolkit.Unity
{
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(HeaderAttribute))]
public class CustomHeaderDrawer : DecoratorDrawer
{
public override float GetHeight()
{
return (MRTKEditor.ShowCustomEditors && MRTKEditor.CustomEditorActive) ? 0f : 24f;
}
public override void OnGUI(Rect position)
{
if (headerStyle == null)
{
headerStyle = new GUIStyle(EditorStyles.boldLabel);
headerStyle.alignment = TextAnchor.LowerLeft;
}
// If we're using MRDL custom editors, don't show the header
if (MRTKEditor.ShowCustomEditors && MRTKEditor.CustomEditorActive)
{
return;
}
// Otherwise draw it normally
GUI.Label(position, (base.attribute as HeaderAttribute).header, headerStyle);
}
private static GUIStyle headerStyle = null;
}
#endif
}