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;
} }

unity调android ios 浏览器 uniwebview2.1使用的更多相关文章

  1. [原]unity调Android(三)

    private UnityPlayer mUnityPlayer;    @Override    protected void onCreate(Bundle savedInstanceState) ...

  2. Android/iOS内嵌Unity开发示例

    Unity 与 Android/iOS 交叉开发主要有两种方式,以 Android 为例,一是 Android 生成 jar 或者 aar 包,导入到 unity3d plugin/bin/ 目录下: ...

  3. unity 与 android 协调工作 注意事项

    原地址:http://blog.csdn.net/u012085988/article/details/17436191 1.unity调android函数 AndroidJavaClass jc = ...

  4. Unity在Android和iOS中如何调用Native API

    本文主要是对unity中如何在Android和iOS中调用Native API进行介绍. 首先unity支持在C#中调用C++ dll,这样可以在Android和iOS中提供C++接口在unity中调 ...

  5. Tomcat双向Https验证搭建,亲自实现与主流浏览器、Android/iOS移动客户端超安全通信

    紧接着<Tomcat单向Https验证搭建,亲自实现与主流浏览器.Android/iOS移动客户端安全通信>,此处演示下更安全的双向Https认证的通信机制,为了清晰明了,以下进行单独描述 ...

  6. Tomcat单向Https验证搭建,亲自实现与主流浏览器、Android/iOS移动客户端安全通信

    众所周知,iOS9已经开始在联网方面默认强制使用Https替换原来的Http请求了,虽然Http和Https各有各的优势,但是总得来说,到了现在这个安全的信息时代,开发者已经离不开Https了. 网上 ...

  7. Unity 5.3.1 No Android/IOS module loaded

    unity我一直在用5.0以下的版本 昨天升级到了最新版本5.3.1 发现无法打android包,ios也不行 提示“No Android/IOS module loaded” 下面有个Module ...

  8. Unity 发布到IOS,Android的各种坑

    Unity 发布到IOS的注意事项1.开发环境MAC环境:Xcode环境 7.2.1Unity环境:Unity5.32.基本说明首先,我说一下,这是我在对Unity发布到IOS的实际使用中,总结出来的 ...

  9. unity 联机调试(android ios)

    http://blog.csdn.net/OnafioO/article/details/44903491 (这种没用,只是在手机看到画面而已) 手机安装unityRemote并运行,unity中设置 ...

随机推荐

  1. POJ 1952 BUY LOW, BUY LOWER 动态规划题解

    Description The advice to "buy low" is half the formula to success in the bovine stock mar ...

  2. wpf中的样式与模板

    1.WPF样式类似于Web应用程序中的CSS,在WPF中可以为控件定义统一的样式(Style).样式属于资源的一种,例如为Button定义统一的背景颜色和字体: <Window.Resource ...

  3. WPF中的数据绑定Data Binding使用小结

    完整的数据绑定的语法说明可以在这里查看: http://www.nbdtech.com/Free/WpfBinding.pdf MSDN资料: Data Binding: Part 1 http:// ...

  4. cURL实现Get和Post

    1.Get请求: //初始化 $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, "http://www.jb51.n ...

  5. xcode升级到6.0以后遇到的警告错误 原帖链接http://www.cocoachina.com/bbs/simple/?t112432.html

    Xcode 升级后,常常遇到的遇到的警告.错误,解决方法 从sdk3.2.5升级到sdk 7.1中间废弃了很多的方法,还有一些逻辑关系更加严谨了.1,警告:“xoxoxoxo”  is depreca ...

  6. WinCE下使用C#的几个小技巧

    1.我们知道,在使用Windows的开发机上用C#启动一个外部程序的方法有很多,但这些方法用在使用WinCE的目标工控机上都无能为力,现在小嫚儿以打开一个IE为例,介绍如何在WinCE下使用C#来打开 ...

  7. 基于EasyDarwin云视频平台的幼儿园视频直播(手机直播/微信直播)解决方案

    一.方案介绍 1.1.方案背景 在2016年10月25日至28日的安博会上,我们看到了不少的幼教平台厂商,我们注意到大部分的幼教平台,为了追求极佳的用户体验,在微信或者APP端能够做到极快的打开速度, ...

  8. httpclient4 模拟访问网页 模拟登录 简单例子

    JAVA后台模拟登录一个网站,获得一定权限后进一步操作. 所用的工具: Apache HttpComponents client 4.3版本 以下为代码: import org.apache.http ...

  9. innodb的锁和高并发

    1 innodb的锁 1.1 s锁,即读锁,即share锁 1.2 x锁,即写锁,排他锁 1.3 s锁和x锁之间的关系 多个读锁可以共存,但是读锁不可以和写锁共存.写锁和写锁不可以共存. 1.4 间隙 ...

  10. const与define应用上该怎么取舍

    const与define应用上该怎么取舍 #define WYB 100; const float WYB = 100; define是在预编译的时候展开替换的,const是编译运行阶段使用 defi ...