Skip to content

Commit 3d3ab91

Browse files
committed
Update FontIconSelectorInspector.cs
1 parent 0295093 commit 3d3ab91

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

org.mixedrealitytoolkit.uxcore/Editor/Inspectors/FontIconSet/FontIconSelectorInspector.cs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Copyright (c) Mixed Reality Toolkit Contributors
32
// Licensed under the BSD 3-Clause
43

@@ -13,12 +12,6 @@ namespace MixedReality.Toolkit.Editor
1312
[CanEditMultipleObjects]
1413
class FontIconSelectorInspector : UnityEditor.Editor
1514
{
16-
17-
private const string defaultShaderName = "TextMeshPro/Distance Field SSD";
18-
private float fontTileSize = 32;
19-
20-
private static Material fontRenderMaterial;
21-
2215
private const string noFontIconsMessage = "No IconFontSet profile selected. No icons available.";
2316
private const string emptyFontIconSetMessage = "The selected IconFontSet profile has no icons defined. Please edit the IconFontSet.";
2417

@@ -29,6 +22,7 @@ class FontIconSelectorInspector : UnityEditor.Editor
2922
private GUIStyle currentButtonStyle;
3023

3124
private bool initializedStyle = false;
25+
private float fontTileSize = 32;
3226

3327
/// <summary>
3428
/// A Unity event function that is called when the script component has been enabled.
@@ -38,7 +32,6 @@ private void OnEnable()
3832
fontIconsProp = serializedObject.FindProperty("fontIcons");
3933
currentIconNameProp = serializedObject.FindProperty("currentIconName");
4034
tmProProp = serializedObject.FindProperty("textMeshProComponent");
41-
4235
}
4336

4437
/// <summary>
@@ -90,7 +83,6 @@ public override void OnInspectorGUI()
9083
}
9184

9285
private int numColumns = 4;
93-
9486
private Vector2 scrollAmount;
9587

9688
public void DrawIconGrid(FontIconSelector fontIconSelector, float tileSize)
@@ -101,45 +93,42 @@ public void DrawIconGrid(FontIconSelector fontIconSelector, float tileSize)
10193

10294
scrollAmount = EditorGUILayout.BeginScrollView(scrollAmount, GUILayout.MaxHeight(128), GUILayout.MinHeight(64));
10395
EditorGUILayout.BeginHorizontal();
104-
96+
10597
foreach (string iconName in fontIconSet.GlyphIconsByName.Keys)
10698
{
10799
uint unicodeValue = fontIconSet.GlyphIconsByName[iconName];
108-
bool selected = (iconName == fontIconSelector.CurrentIconName);
100+
109101
if (column >= numColumns)
110102
{
111103
column = 0;
112104
EditorGUILayout.EndHorizontal();
113105
EditorGUILayout.BeginHorizontal();
114106
}
107+
115108
if (GUILayout.Button(" ",
116-
GUILayout.MinHeight(tileSize),
117-
GUILayout.MaxHeight(tileSize),
118-
GUILayout.MinWidth(tileSize),
119-
GUILayout.MaxWidth(tileSize)))
109+
GUILayout.Height(tileSize),
110+
GUILayout.Width(tileSize)))
120111
{
121-
Undo.RecordObjects(new UnityEngine.Object[]{fontIconSelector, fontIconSelector.TextMeshProComponent}, "Changed icon");
112+
Undo.RecordObjects(new Object[] { fontIconSelector, fontIconSelector.TextMeshProComponent }, "Changed icon");
122113
fontIconSelector.CurrentIconName = iconName;
123114
PrefabUtility.RecordPrefabInstancePropertyModifications(fontIconSelector);
124115
PrefabUtility.RecordPrefabInstancePropertyModifications(fontIconSelector.TextMeshProComponent);
125116
}
117+
126118
Rect textureRect = GUILayoutUtility.GetLastRect();
127119
if (textureRect.yMin + 8 < scrollAmount.y || textureRect.yMax - 8 > scrollAmount.y + 128)
128120
{
129121
unicodeValue = 0;
130122
}
131-
132123
textureRect.width = tileSize;
133124
textureRect.height = tileSize;
134-
FontIconSetInspector.EditorDrawTMPGlyph(textureRect, unicodeValue, fontAsset, selected);
125+
FontIconSetInspector.EditorDrawTMPGlyph(textureRect, unicodeValue, fontAsset, iconName == fontIconSelector.CurrentIconName);
126+
135127
column++;
136128
}
137129

138-
if (column > 0)
139-
{
140-
EditorGUILayout.EndHorizontal();
141-
}
142-
130+
EditorGUILayout.EndHorizontal();
131+
143132
if (Event.current.type == EventType.Repaint)
144133
{
145134
float editorWindowWidth = GUILayoutUtility.GetLastRect().width;

0 commit comments

Comments
 (0)