Skip to content

Commit

Permalink
fix unity 2021 error
Browse files Browse the repository at this point in the history
  • Loading branch information
kou-yeung committed May 23, 2024
1 parent 86f3f27 commit d36d510
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Assets/WebGLSupport/WebGLInput/Wrapper/WrappedUIToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public ContentType contentType
return ContentType.Password;
}

return input.keyboardType switch
#if UNITY_2022_1_OR_NEWER
var keyboardType = input.keyboardType;
#else
var keyboardType = TouchScreenKeyboardType.Default;
#endif
return keyboardType switch
{
TouchScreenKeyboardType.Default => ContentType.Standard,
TouchScreenKeyboardType.ASCIICapable => ContentType.Alphanumeric,
Expand Down Expand Up @@ -94,33 +99,38 @@ public bool isFocused
public int selectionFocusPosition
{
get { return input.cursorIndex; }
#if UNITY_2022_1_OR_NEWER
set { input.cursorIndex = value; }
#else
set { input.SelectRange(value, input.selectIndex); }
#endif
}

public int selectionAnchorPosition
{
get { return input.selectIndex; }
#if UNITY_2022_1_OR_NEWER
set { input.selectIndex = value; }
#else
set { input.SelectRange(input.cursorIndex, value); }
#endif
}

public bool OnFocusSelectAll
{
#if UNITY_2022_1_OR_NEWER
get { return input.selectAllOnFocus || input.selectAllOnMouseUp; }
#else
get { return true; }
#endif
}

public bool EnableMobileSupport
{
get
{
// 2022.1.0f1
// https://unity.com/ja/releases/editor/whats-new/2022.1.0#release-notes
// WebGL: Added mobile keyboard support for WebGL to enter text in UI input fields.
#if UNITY_2022_1_OR_NEWER
// return false to use unity mobile keyboard support
return false;
#else
return true;
#endif
}
}

Expand Down

0 comments on commit d36d510

Please sign in to comment.