AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CustomHeaderDrawer.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Text.RegularExpressions;
5 using UnityEngine;
6 #if UNITY_EDITOR
7 using UnityEditor;
8 #endif
9 
10 namespace HoloToolkit.Unity
11 {
12 #if UNITY_EDITOR
13  [CustomPropertyDrawer(typeof(HeaderAttribute))]
14  public class CustomHeaderDrawer : DecoratorDrawer
15  {
16  public override float GetHeight()
17  {
18  return (MRTKEditor.ShowCustomEditors && MRTKEditor.CustomEditorActive) ? 0f : 24f;
19  }
20 
21  public override void OnGUI(Rect position)
22  {
23  if (headerStyle == null)
24  {
25  headerStyle = new GUIStyle(EditorStyles.boldLabel);
26  headerStyle.alignment = TextAnchor.LowerLeft;
27  }
28 
29  // If we're using MRDL custom editors, don't show the header
30  if (MRTKEditor.ShowCustomEditors && MRTKEditor.CustomEditorActive)
31  {
32  return;
33  }
34 
35  // Otherwise draw it normally
36  GUI.Label(position, (base.attribute as HeaderAttribute).header, headerStyle);
37  }
38 
39  private static GUIStyle headerStyle = null;
40  }
41 #endif
42 
43 }