TextMeshPro无法弹出输入框
问题描述
使用团结引擎的文本渲染工具TextMeshPro时,无法弹出输入框。
解决方案
TextMeshPro虽然已适配HarmonyOS系统,但未同步到packageManager上,目前可以暂时规避。
-
方案一:
- 找到并删除工程/Library/PackageCache路径下的com.UXX.textmeshpro文件。
- 您可以前往Gitee网站下载已适配HarmonyOS的textmeshpro文件,解压后放至工程/packages路径下。
-
方案二:
-
剪切工程/Library/PackageCache路径下的com.UXX.textmeshpro文件,拷贝至工程/packages路径下。
-
您可以参考如下示例代码自行修改TMP_InputField.cs文件:
public bool shouldHideSoftKeyboard
{
get
{
switch (Application.platform)
{
case RuntimePlatform.Android:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.tvOS:
case RuntimePlatform.WSAPlayerX86:
case RuntimePlatform.WSAPlayerX64:
case RuntimePlatform.WSAPlayerARM:
case RuntimePlatform.Stadia:
case RuntimePlatform.OpenHarmony:
#if UXX_2020_2_OR_NEWER
case RuntimePlatform.PS4:
#if !(UXX_2020_2_1 || UXX_2020_2_2)
case RuntimePlatform.PS5:
#endif
#endif
case RuntimePlatform.Switch:
return m_HideSoftKeyboard;
default:
return true;
}
}
set
{
switch (Application.platform)
{
case RuntimePlatform.Android:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.tvOS:
case RuntimePlatform.WSAPlayerX86:
case RuntimePlatform.WSAPlayerX64:
case RuntimePlatform.WSAPlayerARM:
case RuntimePlatform.Stadia:
case RuntimePlatform.OpenHarmony:
#if UXX_2020_2_OR_NEWER
case RuntimePlatform.PS4:
#if !(UXX_2020_2_1 || UXX_2020_2_2)
case RuntimePlatform.PS5:
#endif
#endif
case RuntimePlatform.Switch:
SetPropertyUtility.SetStruct(ref m_HideSoftKeyboard, value);
break;
default:
m_HideSoftKeyboard = true;
break;
}
if (m_HideSoftKeyboard == true && m_SoftKeyboard != null && TouchScreenKeyboard.isSupported && m_SoftKeyboard.active)
{
m_SoftKeyboard.active = false;
m_SoftKeyboard = null;
}
}
} -
在RuntimePlatform.Android、UXX_ANDROID、UXX_MOBILE和shouldHideMobilelnput修改一致,在相应位置通过RuntimePlatform.OpenHarmony和UXX_OPENHARMONY加上HarmonyOS平台的处理逻辑即可。
-