Skip to content

Commit 113bfa5

Browse files
committed
Add check for TouchScreenKeyboard.isSupported
1 parent 4e97724 commit 113bfa5

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

UnityProjects/MRTKDevTemplate/Assets/Scripts/SystemKeyboardExample.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright (c) Mixed Reality Toolkit Contributors
22
// Licensed under the BSD 3-Clause
33

4-
// Disable "missing XML comment" warning for samples. While nice to have, this XML documentation is not required for samples.
5-
#pragma warning disable CS1591
6-
7-
using MixedReality.Toolkit.Input;
84
using MixedReality.Toolkit.UX;
95
using TMPro;
106
using UnityEngine;
@@ -30,10 +26,8 @@ public class SystemKeyboardExample : MonoBehaviour
3026
[SerializeField]
3127
private TextMeshPro debugMessage = null;
3228

33-
#pragma warning disable 0414
3429
[SerializeField]
3530
private KeyboardPreview mixedRealityKeyboardPreview = null;
36-
#pragma warning restore 0414
3731

3832
/// <summary>
3933
/// Opens a platform specific keyboard.
@@ -43,15 +37,18 @@ public void OpenSystemKeyboard()
4337
#if WINDOWS_UWP
4438
wmrKeyboard.ShowKeyboard(wmrKeyboard.Text, false);
4539
#elif UNITY_IOS || UNITY_ANDROID
46-
touchscreenKeyboard = TouchScreenKeyboard.Open(string.Empty, TouchScreenKeyboardType.Default, false, false, false, false);
40+
if (TouchScreenKeyboard.isSupported)
41+
{
42+
touchscreenKeyboard = TouchScreenKeyboard.Open(string.Empty, TouchScreenKeyboardType.Default, false, false, false, false);
43+
}
4744
#endif
4845
}
4946

5047
#region MonoBehaviour Implementation
5148

5249
/// <summary>
5350
/// A Unity event function that is called on the frame when a script is enabled just before any of the update methods are called the first time.
54-
/// </summary>
51+
/// </summary>
5552
private void Start()
5653
{
5754
// Initially hide the preview.
@@ -91,7 +88,6 @@ private void Start()
9188
#endif
9289
}
9390

94-
9591
#if WINDOWS_UWP
9692
/// <summary>
9793
/// A Unity event function that is called every frame, if this object is enabled.
@@ -149,19 +145,19 @@ private void Update()
149145
// touch screen keyboard.
150146
if (touchscreenKeyboard != null)
151147
{
152-
string KeyboardText = touchscreenKeyboard.text;
148+
string keyboardText = touchscreenKeyboard.text;
153149
if (TouchScreenKeyboard.visible)
154150
{
155151
if (debugMessage != null)
156152
{
157-
debugMessage.text = "typing... " + KeyboardText;
153+
debugMessage.text = "typing... " + keyboardText;
158154
}
159155
}
160156
else
161157
{
162158
if (debugMessage != null)
163159
{
164-
debugMessage.text = "typed " + KeyboardText;
160+
debugMessage.text = "typed " + keyboardText;
165161
}
166162

167163
touchscreenKeyboard = null;
@@ -173,4 +169,3 @@ private void Update()
173169
#endregion MonoBehaviour Implementation
174170
}
175171
}
176-
#pragma warning restore CS1591

0 commit comments

Comments
 (0)