Skip to content

Commit 5cc4485

Browse files
authored
Merge pull request #43 from jacklul/uistyler-patch1
Fixes crash when used on completely custom UI with TMPro Input Fields
2 parents e1238e8 + e9b5439 commit 5cc4485

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Assets/USharpVideo/Scripts/UI/UIStyler.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using TMPro;
23
using UnityEngine;
34
using System.Reflection;
45
using System.IO;
@@ -67,35 +68,48 @@ public void ApplyStyle()
6768
if (markup.styleClass == UIStyleMarkup.StyleClass.TextHighlight)
6869
{
6970
InputField input = markup.GetComponent<InputField>();
71+
TMP_InputField inputTmp = markup.GetComponent<TMP_InputField>();
72+
VRCUrlInputField vrcInput = markup.GetComponent<VRCUrlInputField>();
7073

7174
if (input != null)
7275
{
7376
Undo.RecordObject(input, "Apply UI Style");
7477
input.selectionColor = graphicColor;
7578
RecordObject(input);
7679
}
77-
else
80+
else if (inputTmp != null)
81+
{
82+
Undo.RecordObject(inputTmp, "Apply UI Style");
83+
inputTmp.selectionColor = graphicColor;
84+
RecordObject(inputTmp);
85+
}
86+
else if (vrcInput != null)
7887
{
79-
VRCUrlInputField vrcInput = markup.GetComponent<VRCUrlInputField>();
8088
Undo.RecordObject(vrcInput, "Apply UI Style");
8189
vrcInput.selectionColor = graphicColor;
8290
RecordObject(vrcInput);
8391
}
84-
8592
}
8693
else if (markup.styleClass == UIStyleMarkup.StyleClass.TextCaret)
8794
{
8895
InputField input = markup.GetComponent<InputField>();
96+
TMP_InputField inputTmp = markup.GetComponent<TMP_InputField>();
97+
VRCUrlInputField vrcInput = markup.GetComponent<VRCUrlInputField>();
8998

9099
if (input != null)
91100
{
92101
Undo.RecordObject(input, "Apply UI Style");
93102
input.caretColor = graphicColor;
94103
RecordObject(input);
95104
}
96-
else
105+
else if (inputTmp != null)
106+
{
107+
Undo.RecordObject(inputTmp, "Apply UI Style");
108+
inputTmp.caretColor = graphicColor;
109+
RecordObject(inputTmp);
110+
}
111+
else if (vrcInput != null)
97112
{
98-
VRCUrlInputField vrcInput = markup.GetComponent<VRCUrlInputField>();
99113
Undo.RecordObject(vrcInput, "Apply UI Style");
100114
vrcInput.caretColor = graphicColor;
101115
RecordObject(vrcInput);

0 commit comments

Comments
 (0)