fix:1、修复bug
This commit is contained in:
@@ -23,40 +23,6 @@ public class FreeWebViewManager : MonoBehaviour
|
||||
}
|
||||
|
||||
public void initView()
|
||||
{
|
||||
if (_webObj != null) return;
|
||||
|
||||
// 创建WebView对象
|
||||
_webObj = new GameObject("WebViewObject1");
|
||||
_webView = _webObj.AddComponent<WebViewObject1>();
|
||||
|
||||
// 关键:开启WKWebView,规避苹果审核拒绝
|
||||
_webView.Init(
|
||||
enableWKWebView: true,
|
||||
cb: OnWebMessage // JS调用Unity回调
|
||||
);
|
||||
|
||||
float top_offset = 0;//fgui中的顶部信息的高度
|
||||
float buttom_offset = 155;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
top_offset += Screen.safeArea.y;
|
||||
}
|
||||
|
||||
// 铺满屏幕,适配刘海安全区
|
||||
_webView.SetMargins(0, (int)top_offset, 0, (int)buttom_offset);
|
||||
// 禁止下拉回弹(可选)
|
||||
_webView.SetScrollBounceEnabled(false);
|
||||
|
||||
_webView.LoadURL("about:blank");
|
||||
_webView.SetVisibility(false);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开网页
|
||||
/// </summary>
|
||||
public void OpenWeb(string url)
|
||||
{
|
||||
// if (_webObj != null) return;
|
||||
//
|
||||
@@ -82,6 +48,40 @@ public class FreeWebViewManager : MonoBehaviour
|
||||
// // 禁止下拉回弹(可选)
|
||||
// _webView.SetScrollBounceEnabled(false);
|
||||
//
|
||||
// _webView.LoadURL("about:blank");
|
||||
// _webView.SetVisibility(false);
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开网页
|
||||
/// </summary>
|
||||
public void OpenWeb(string url)
|
||||
{
|
||||
if (_webObj != null) return;
|
||||
|
||||
// 创建WebView对象
|
||||
_webObj = new GameObject("WebViewObject1");
|
||||
_webView = _webObj.AddComponent<WebViewObject1>();
|
||||
|
||||
// 关键:开启WKWebView,规避苹果审核拒绝
|
||||
_webView.Init(
|
||||
enableWKWebView: true,
|
||||
cb: OnWebMessage // JS调用Unity回调
|
||||
);
|
||||
|
||||
float top_offset = 0;//fgui中的顶部信息的高度
|
||||
float buttom_offset = 155;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
top_offset += Screen.safeArea.y;
|
||||
}
|
||||
|
||||
// 铺满屏幕,适配刘海安全区
|
||||
_webView.SetMargins(0, (int)top_offset, 0, (int)buttom_offset);
|
||||
// 禁止下拉回弹(可选)
|
||||
_webView.SetScrollBounceEnabled(false);
|
||||
|
||||
// 加载网页并显示
|
||||
_webView.LoadURL(url);
|
||||
_webView.SetVisibility(true);
|
||||
@@ -107,7 +107,7 @@ public class FreeWebViewManager : MonoBehaviour
|
||||
{
|
||||
if (_webObj != null)
|
||||
{
|
||||
_webView.SetVisibility(false);
|
||||
OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user