Skip to content

Commit d36d510

Browse files
committed
fix unity 2021 error
1 parent 86f3f27 commit d36d510

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Assets/WebGLSupport/WebGLInput/Wrapper/WrappedUIToolkit.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ public ContentType contentType
4545
return ContentType.Password;
4646
}
4747

48-
return input.keyboardType switch
48+
#if UNITY_2022_1_OR_NEWER
49+
var keyboardType = input.keyboardType;
50+
#else
51+
var keyboardType = TouchScreenKeyboardType.Default;
52+
#endif
53+
return keyboardType switch
4954
{
5055
TouchScreenKeyboardType.Default => ContentType.Standard,
5156
TouchScreenKeyboardType.ASCIICapable => ContentType.Alphanumeric,
@@ -94,33 +99,38 @@ public bool isFocused
9499
public int selectionFocusPosition
95100
{
96101
get { return input.cursorIndex; }
102+
#if UNITY_2022_1_OR_NEWER
97103
set { input.cursorIndex = value; }
104+
#else
105+
set { input.SelectRange(value, input.selectIndex); }
106+
#endif
98107
}
99108

100109
public int selectionAnchorPosition
101110
{
102111
get { return input.selectIndex; }
112+
#if UNITY_2022_1_OR_NEWER
103113
set { input.selectIndex = value; }
114+
#else
115+
set { input.SelectRange(input.cursorIndex, value); }
116+
#endif
104117
}
105118

106119
public bool OnFocusSelectAll
107120
{
121+
#if UNITY_2022_1_OR_NEWER
108122
get { return input.selectAllOnFocus || input.selectAllOnMouseUp; }
123+
#else
124+
get { return true; }
125+
#endif
109126
}
110127

111128
public bool EnableMobileSupport
112129
{
113130
get
114131
{
115-
// 2022.1.0f1
116-
// https://unity.com/ja/releases/editor/whats-new/2022.1.0#release-notes
117-
// WebGL: Added mobile keyboard support for WebGL to enter text in UI input fields.
118-
#if UNITY_2022_1_OR_NEWER
119132
// return false to use unity mobile keyboard support
120133
return false;
121-
#else
122-
return true;
123-
#endif
124134
}
125135
}
126136

0 commit comments

Comments
 (0)