赞
踩
unity 内嵌H5界面需要用到Uniwebview 差件,百度搜索下就可以找到插件下载地址,这里就不提供了
Uniwebview 支持Android 、IOS。 PC平台下不显示,需要打包测试。
下面是封装好的动态加载外部网页类
using System;
using UnityEngine;
public class WebView : Singleton {
public delegate void WebOnReceivedMessage(UniWebView webView, UniWebViewMessage message);
public WebOnReceivedMessage OnWebReceivedMessage;
#if !(UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN)
private UniWebView webView;
#endif
private Action onClose;
private void CreateWebView(Rect panelPosition,Action loadFinished = null) {
#if !(UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN)
if (this.webView == null) {
this.webView = this.gameObject.AddComponent();
}
int top, left, bottom, right;
#if UNITY_ANDROID
left = (int)panelPosition.x;
top = (int)panelPosition.y;
bottom = (int)(Screen.height - panelPosition.height - top);
right = (int)(Screen.width - panelPosition.width - left) ;
#endif
#if UNITY_IOS
float ratio;
ratio = 1f / UniWebViewHelper.screenScale;
left = (int)(panelPosition.x * ratio);
top = (int)(
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。