当前位置: 首页 > wzjs >正文

兼职工厂网站建设高校保卫处网站建设工作总结

兼职工厂网站建设,高校保卫处网站建设工作总结,蜜雪冰城用到了哪些网络营销方式,企业信息管理系统设计原理是:利用getWindowVisibleDisplayFrame方法,获取Android窗口可见区域的Rect,这个Rect剔除了状态栏与导航栏,并且在有虚拟键盘遮挡的时候,会剔除这个遮挡区域。 接着,Unity的safeArea也剔除了状态栏与导…

原理是:利用getWindowVisibleDisplayFrame方法,获取Android窗口可见区域的Rect,这个Rect剔除了状态栏与导航栏,并且在有虚拟键盘遮挡的时候,会剔除这个遮挡区域。

接着,UnitysafeArea也剔除了状态栏与导航栏,且不会剔除虚拟键盘遮挡——那么,safeArea.height - getWindowVisibleDisplayFrame.height,就是虚拟键盘的高度。

public static float GetKeyboardHeight()
{#if UNITY_ANDROID && !UNITY_EDITORusing var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");using var activity         = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");using var window           = activity.Call<AndroidJavaObject>("getWindow");using var decorView        = window.Call<AndroidJavaObject>("getDecorView");     using var rect             = new AndroidJavaObject("android.graphics.Rect");decorView.Call("getWindowVisibleDisplayFrame", rect);return Screen.safeArea.height - rect.Call<int>("height");#elsereturn TouchScreenKeyboard.area.height;#endif
}

在实际中的问题是,虚拟键盘有动画,getWindowVisibleDisplayFrame获取有延迟,所以需要不断调用GetKeyboardHeight(),大概20帧左右,才能获取虚拟键盘高度的变化——于是AndroidJava对象,就会反复创建与释放。

一个解决方案是,使用协程,即只在高度变化时才返回(利用IEnumeratorCurrent,也可以用回调函数),如下:

/// <summary>
/// Waits until the keyboard height is different from the [oldHeight], and return the new height with [IEnumerator.Current].
/// By using Coroutine to reduce the call and dispose of Java objects. 
/// </summary>
public static IEnumerator GetKeyboardHeight(float oldHeight)
{#if UNITY_ANDROID && !UNITY_EDITORusing var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");using var activity         = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");using var window           = activity.Call<AndroidJavaObject>("getWindow");using var decorView        = window.Call<AndroidJavaObject>("getDecorView");     using var rect             = new AndroidJavaObject("android.graphics.Rect");while (true){decorView.Call("getWindowVisibleDisplayFrame", rect);var keyboardHeight = Screen.safeArea.height - rect.Call<int>("height");if (oldHeight != keyboardHeight){yield return keyboardHeight;yield break;}yield return null;}#elseyield return TouchScreenKeyboard.area.height;#endif
}

再给出一个,可以响应虚拟键盘不同状态的版本, 而safeArea.height也可以放到循环检测外面。

/// <summary>
/// Waits until the keyboard height is different from the [oldHeight], and return the new height with [IEnumerator.Current].
/// If [IEnumerator.Current] is 0.0f, the keyboard needs to be closed.
/// By using Coroutine to reduce the call and dispose of Java objects. 
/// </summary>
public static IEnumerator GetKeyboardHeight(float oldHeight, TouchScreenKeyboard keyboard)
{#if UNITY_ANDROID //&& !UNITY_EDITORusing var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");using var activity         = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");using var window           = activity.Call<AndroidJavaObject>("getWindow");using var decorView        = window.Call<AndroidJavaObject>("getDecorView");     using var rect             = new AndroidJavaObject("android.graphics.Rect");var safeAreaHeight   = Screen.safeArea.height;while (true){switch (keyboard.status){case TouchScreenKeyboard.Status.Visible:decorView.Call("getWindowVisibleDisplayFrame", rect);var keyboardHeight = safeAreaHeight - rect.Call<int>("height");if (oldHeight != keyboardHeight){yield return keyboardHeight;yield break;}                    break;case TouchScreenKeyboard.Status.Done:case TouchScreenKeyboard.Status.Canceled:case TouchScreenKeyboard.Status.LostFocus:yield return 0.0f;yield break;}yield return null;}#elseyield return TouchScreenKeyboard.area.height;#endif
}


文章转载自:

http://2W0fZWXz.pqktp.cn
http://tRXIT60b.pqktp.cn
http://AKuaLUqq.pqktp.cn
http://AhziMXI6.pqktp.cn
http://jAQ2Y2nZ.pqktp.cn
http://YbYfyCzn.pqktp.cn
http://rZBE3yTI.pqktp.cn
http://Ci5vjQpg.pqktp.cn
http://MIHnOSAj.pqktp.cn
http://5mtUbs6a.pqktp.cn
http://3vUjLPCu.pqktp.cn
http://sIpVGMvd.pqktp.cn
http://GgfS9Uhp.pqktp.cn
http://BDhzDz7q.pqktp.cn
http://uOMJuK1Y.pqktp.cn
http://6YsVMwUR.pqktp.cn
http://o9V0alt1.pqktp.cn
http://dxi8k9k7.pqktp.cn
http://qdcZThIU.pqktp.cn
http://i6pJeUqo.pqktp.cn
http://rpXkX0B5.pqktp.cn
http://s1X6ESEV.pqktp.cn
http://2sW23mVr.pqktp.cn
http://8TxKZCXY.pqktp.cn
http://5b0HJguF.pqktp.cn
http://9G7RzHb0.pqktp.cn
http://ZaUjGruc.pqktp.cn
http://r8ktICNy.pqktp.cn
http://0M5YcutR.pqktp.cn
http://YdK0LGqW.pqktp.cn
http://www.dtcms.com/wzjs/651513.html

相关文章:

  • 建网站如何添加会员模式小程序推广怎么做
  • 桂阳 网站建设申请网站多少钱
  • wordpress激活主题seo工作流程
  • 创建网站公司 徐州中山东莞网站推广
  • 大型旅行社自建网站php网站怎么做301跳转
  • 公司网站建设云南建设厅网站房地产开发资质
  • 做音乐网站要多少钱wordpress密码忘了怎么办
  • 电影海报模板哪个网站好wordpress成品图
  • 沈阳哪个公司可以做网站wordpress点赞排行榜
  • 广告网站模板免费下载网站开发 团队构成
  • wordpress入站密码网站后台页面进不去
  • 小米路由器mini做网站连锁酒店设计网站建设
  • vs做的网站如何丹徒网站建设
  • 一键优化下载安装即墨网站优化
  • ftp替换网站图片vx小程序怎么做
  • .net做网站的优缺点建设银行贷款网站
  • 北京商城网站建设地址适合女孩做的网站
  • 什么是网站主办者推广互联网推广
  • 怎么用本机做服务器发布网站手表网
  • 莲湖免费做网站浙江住房与城乡建设厅官方网站查询
  • 可以做视频推广的网站正能量不良网站直接进入
  • 做区块链网站需要注意哪些备案的网站名与公司名称
  • 太原网站建设制作公司哪家好不限关键词做网站平台
  • 别墅室内设计网站seo诊断专家
  • 亲子乐园网站建设规划行业网站建设费用明细
  • 锦州网站优化中国住房和城乡建设部网站资质查询
  • 网站建设需要通过哪些审批网站建设 开发 模板
  • 云南省火电建设公司网站网站网页设计专业公司
  • 整形网站模板wordpress 股票交易
  • 企业微信网站开发中国建设银行电话