AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
TextAreaProp.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 System;
5 using System.Reflection;
6 using UnityEngine;
7 #if UNITY_EDITOR
8 using UnityEditor;
9 #endif
10 
11 namespace HoloToolkit.Unity
12 {
13  // Displays a text property as a text area
14  [AttributeUsage(AttributeTargets.Property)]
15  public sealed class TextAreaProp : DrawOverrideAttribute
16  {
17  public int FontSize { get; private set; }
18 
19  public TextAreaProp(int fontSize = -1)
20  {
21  FontSize = fontSize;
22  }
23 
24 #if UNITY_EDITOR
25  public override void DrawEditor(UnityEngine.Object target, FieldInfo field, SerializedProperty property)
26  {
27  throw new NotImplementedException();
28  }
29 
30  public override void DrawEditor(UnityEngine.Object target, PropertyInfo prop)
31  {
32  string propValue = (string)prop.GetValue(target, null);
33  EditorGUILayout.LabelField(SplitCamelCase(prop.Name), EditorStyles.miniBoldLabel);
34  GUIStyle textAreaStyle = EditorStyles.textArea;
35  if (FontSize > 0)
36  {
37  textAreaStyle.fontSize = FontSize;
38  }
39  propValue = EditorGUILayout.TextArea(propValue, textAreaStyle);
40  prop.SetValue(target, propValue, null);
41  }
42 #endif
43 
44  }
45 }
TextAreaProp(int fontSize=-1)
Definition: TextAreaProp.cs:19