AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
KeywordAndKeyCodeDrawer.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 using UnityEditor;
6 
7 namespace HoloToolkit.Unity.InputModule
8 {
9  [CustomPropertyDrawer(typeof(KeywordAndKeyCode))]
10  public class KeywordAndKeyCodeDrawer : PropertyDrawer
11  {
12  public override void OnGUI(Rect rect, SerializedProperty property, GUIContent content)
13  {
14  EditorGUI.BeginProperty(rect, content, property);
15 
16  // calculate field rectangle with half of total drawer length for each
17  float fieldWidth = rect.width * 0.5f;
18  Rect keywordRect = new Rect(rect.x, rect.y, fieldWidth, rect.height);
19  Rect keyCodeRect = new Rect(rect.x + fieldWidth, rect.y, fieldWidth, rect.height);
20 
21  // the Keyword field without label
22  EditorGUI.PropertyField(keywordRect, property.FindPropertyRelative("Keyword"), GUIContent.none);
23  // the KeyCode field without label
24  EditorGUI.PropertyField(keyCodeRect, property.FindPropertyRelative("KeyCode"), GUIContent.none);
25 
26  EditorGUI.EndProperty();
27  }
28  }
29 }
override void OnGUI(Rect rect, SerializedProperty property, GUIContent content)