unity调android ios 浏览器 uniwebview2.1使用
来源:互联网 发布:黄多多心机知乎 编辑:程序博客网 时间:2024/04/29 17:18
uniwebview2.1使用
插件下载地址:
http://download.csdn.net/detail/onafioo/9576200
示例
public class BrowserMgr {private static UniWebView _webView;static GameObject BrowserGo;public static void Open(string url){if(!CheckURL(url)){Debug.Log("[N]---browser url error!! url:"+url);return;}if(null == BrowserGo)BrowserGo = new GameObject("browser");_webView = BrowserGo.GetComponent<UniWebView>();if (_webView == null) {_webView = BrowserGo.AddComponent<UniWebView>();_webView.OnReceivedMessage += OnReceivedMessage;_webView.OnLoadComplete += OnLoadComplete;_webView.OnWebViewShouldClose += OnWebViewShouldClose;//_webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished;_webView.InsetsForScreenOreitation += InsetsForScreenOreitation;}int bottomInset = (int)(UniWebViewHelper.screenHeight);_webView.insets = new UniWebViewEdgeInsets(0,0,0,0);_webView.url = url;//_webView.url = "http://uniwebview.onevcat.com/demo/index1-1.html";//_webView.url = "http://192.168.12.110:8401/t.html";//_webView.url = "http://www.sina.com.cn/";_webView.SetSpinnerLabelText("载入中...");_webView.SetShowSpinnerWhenLoading(true);Debug.Log("URL:"+_webView.url);ShowViewEventArgs e = new ShowViewEventArgs(ViewNames.HomeView.ToString(), true, true, true);App.Instance.EventManager.SendEvent(e);_webView.Load();}/// <summary>/// 浏览器载入成功回调/// </summary>/// <param name="webView">Web view.</param>/// <param name="success">If set to <c>true</c> success.</param>/// <param name="errorMessage">Error message.</param>static void OnLoadComplete(UniWebView webView, bool success, string errorMessage) {if (success) {Debug.Log("[N]---browser load complete!");webView.Show();} else {Debug.Log("[N]---Something wrong in webview loading: " + errorMessage);}}/// <summary>/// 页面标签信息回调/// </summary>/// <param name="webView">Web view.</param>/// <param name="message">Message.</param>static void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) {Debug.Log("[N]---"+message.rawMessage);//NTODO 处理下必要的页面标签返回信息}/// <summary>/// 弹出Alert/// </summary>/// <param name="alert">Alert.</param>public void ShowAlertInWebview(string alert) {_webView.EvaluatingJavaScript(alert);}/// <summary>/// 浏览器关闭回调/// </summary>/// <param name="webView">Web view.</param>static bool OnWebViewShouldClose(UniWebView webView) {Debug.Log("[N]---browser close!");if (webView == _webView) {_webView = null;return true;}return false;}/// <summary>/// 横竖屏切换/// </summary>/// <returns>The for screen oreitation.</returns>/// <param name="webView">Web view.</param>/// <param name="orientation">Orientation.</param>static UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation) {int bottomInset = (int)(UniWebViewHelper.screenHeight);if (orientation == UniWebViewOrientation.Portrait) return new UniWebViewEdgeInsets(0,0,bottomInset,0);else return new UniWebViewEdgeInsets(0,0,bottomInset,0);}/// <summary>/// 检测URL合法性/// </summary>/// <returns><c>true</c>, if UR was checked, <c>false</c> otherwise.</returns>/// <param name="url">URL.</param>static bool CheckURL(string url){bool b = false;b = Regex.IsMatch(url,"^http://[a-z0-9A-Z.-]*");return b;}}
0 0
- unity调android ios 浏览器 uniwebview2.1使用
- Unity插件使用--UniWebView2
- Unity使用ShareSDK 分享、并发布Android及ios
- Unity跨iOS、Android平台使用protobuf-net的方法
- 使用谷歌浏览器模拟微信(android或ios)浏览器
- unity 使用xcode5.1 launching iOS project via Xcode4 failed
- unity 使用xcode5.1 launching iOS project via Xcode5 failed
- android使用浏览器示例
- 使用AdMob和Unity [Android]
- Unity播放视频(pc,android,ios)
- Unity播放视频(pc,android,ios) 。。整理。。
- Unity Android/IOS 多点触摸实例
- Unity播放视频(pc,android,ios)
- unity 联机调试(android ios)
- Unity IOS Android 消息推送原理分析
- Unity调用Android与IOS平台代码
- Unity-android/iOS自动设置ProjectSetting
- Unity 构建IOS和ANDROID工程 (一)
- 梯度下降法与牛顿法
- Android中跨进程通信方式之使用文件共享
- 在iOS开发为什么使用多线程 ,多线程有哪些方法
- Sed 命令详解
- APIStore使用例子(获取易源笑话)
- unity调android ios 浏览器 uniwebview2.1使用
- Android studio和Eclipse分别生成jar包并混淆jar包
- 关于java部分知识点的总结(一)
- mfc加载png
- sql server2000导出表结构说明
- Mac系统优化
- Android中跨进程通信方式之使用Bundle
- CodePush 热更新React-Native(ios)
- hdu 2157 How many ways?? 矩阵快速幂