Tanoda
LeapTextRendererDrawer.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System.Collections;
10using System.Collections.Generic;
11using UnityEngine;
12using UnityEditor;
13
15
16 [CustomPropertyDrawer(typeof(LeapTextRenderer))]
18 private static float HELP_BOX_HEIGHT = EditorGUIUtility.singleLineHeight * 2;
19
20 protected override void init(SerializedProperty property) {
21 base.init(property);
22
23 drawCustom(rect => { }, EditorGUIUtility.singleLineHeight * 0.5f);
24
25 drawCustom(rect => EditorGUI.LabelField(rect, "Text Settings", EditorStyles.boldLabel),
26 EditorGUIUtility.singleLineHeight);
27
28 var fontProp = property.FindPropertyRelative("_font");
29 drawCustom(rect => {
30 Font font = fontProp.objectReferenceValue as Font;
31 if (font != null && !font.dynamic) {
32 rect.height = HELP_BOX_HEIGHT;
33 EditorGUI.HelpBox(rect, "Only dynamic fonts are currently supported.", MessageType.Error);
34 rect.y += HELP_BOX_HEIGHT;
35 }
36 rect.height = EditorGUIUtility.singleLineHeight;
37 EditorGUI.PropertyField(rect, fontProp);
38 }, () => {
39 Font font = fontProp.objectReferenceValue as Font;
40 if (font != null && !font.dynamic) {
41 return HELP_BOX_HEIGHT + EditorGUIUtility.singleLineHeight;
42 } else {
43 return EditorGUIUtility.singleLineHeight;
44 }
45 });
46
47 drawProperty("_dynamicPixelsPerUnit");
48 drawProperty("_useColor");
49 drawPropertyConditionally("_globalTint", "_useColor");
50 drawProperty("_shader");
51 drawProperty("_scale");
52 }
53
54 }
55}
56
void drawProperty(string name, bool includeChildren=true, bool disable=false)
void drawCustom(Action< Rect > drawFunc, float height)
void drawPropertyConditionally(string propertyName, string conditionalName, bool includeChildren=true)
override void init(SerializedProperty property)