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. 多线程(C++)临界区Critical Sections

    一 .Critical Sections(功能与Mutex相同,保证某一时刻只有一个线程能够访问共享资源,但是不是内核对象,所以访问速度比Mutex快,但是没有等待超时的功能,所以有可能导致死锁,使用 ...

  2. multiTarget within one project pods manage

    step1:file->new->target create 1 targetstep2:change Podfile and update podstep3:check new targ ...

  3. 【BZOJ1064】[Noi2008]假面舞会 DFS树

    [BZOJ1064][Noi2008]假面舞会 Description 一年一度的假面舞会又开始了,栋栋也兴致勃勃的参加了今年的舞会.今年的面具都是主办方特别定制的.每个参加舞会的人都可以在入场时选择 ...

  4. sharding-jdbc源码学习(一)简介

    背景 对于大型的互联网应用来说,数据库单表的记录行数可能达到千万级甚至是亿级,并且数据库面临着极高的并发访问.采用Master-Slave复制模式的MySQL架构,只能够对数据库的读进行扩展,而对数据 ...

  5. HDU2049 不容易系列之(4)考新郎 —— 错排

    题目链接:https://vjudge.net/problem/HDU-2049 不容易系列之(4)——考新郎 Time Limit: 2000/1000 MS (Java/Others)    Me ...

  6. BestCoder Round #92 1001 Skip the Class —— 字典树 or map容器

    题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1001 题解: 1.trie树 关 ...

  7. 自动化测试框架selenium+java+TestNG——配置篇

    最近来总结下自动化测试 selenium的一些常用框架测试搭配,由简入繁,最简单的就是selenium+java+TestNG了,因为我用的是java,就只是总结下java了. TestNG在线安装: ...

  8. LDAP解释(转)

    我要着重指出,LDAP是一个数据库,但是又不是一个数据库.说他是数据库,因为他是一个数据存储的东西.但是说他不是数据库,是因为他的作用没有数据库这么强大,而是一个目录. 为了理解,给一个例子就是电话簿 ...

  9. hdu 1209 Clock(排序)

    题意:按钟表的时针.分针的夹角对5个时间进行升序排序,输出第3个时间 思路:排序 注意:若夹角相同,则按时间进行升序排序 #include<iostream> #include<st ...

  10. VC6.0 快捷键

    F1: 帮助 Ctrl+O   :OpenCtrl+P   :PrintCtrl+N   :NewCtrl+Shift+F2 :清除所有书签F2    :上一个书签Shift+F2 :上一个书签Alt ...