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. 果壳、推库、虎秀、知乎、it世界

    果壳.推库.虎秀.知乎.it世界

  2. android-async-http框架

    android-async-http 简单介绍:An asynchronous, callback-based Http client for Android built on top of Apac ...

  3. EasyVideoRecorder短视频拍摄、短视频录制SDK支持IOS版本

    在前面的博客<EasyDarwin开发出类似于美拍.秒拍的短视频拍摄SDK:EasyVideoRecorder>和<美拍.秒拍中安卓.IOS短视频拍摄的一些关键技术>中我们简单 ...

  4. Timing breakdown phases explained

    https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#timing-explana ...

  5. Object/Relational Mapping 数学关系 反面向对象

    [hibernate ORM 是对象关系映射框架 事实上的持久化存储引擎] http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/ ...

  6. tornado之表单和模板

    之前在indexHandler中通过self.write()方法在对应的网页中写入具体的字符信息. 如果我们想直接返回一个网页那么这个时候就需要用到模板了 首先在工程目录下新建一个template文件 ...

  7. Idea操作与问题解决

    1,.properties文件汉字编码出错 主要是Editer的Encoding出错,可在File->settings->Editer->FileEncoding中修改为: 可参考: ...

  8. Codeforces Round #254 (Div. 2) A. DZY Loves Chessboard —— dfs

    题目链接: http://codeforces.com/problemset/problem/445/A 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...

  9. SCAU RP Test —— 因式分解与组合

    D  RP Test Time Limit:1000MS  Memory Limit:65535K 题型: 编程题   语言: 无限制 描述 LRC是SCAU_ACM校队的主席,职业生涯为校队作过很多 ...

  10. codeforces A. Nuts 解题报告

    题目链接:http://codeforces.com/problemset/problem/402/A 题目意思:几经辛苦,终于体明题目噶意思了 = =,完全是考验一个人是否清醒的最简便方法- -! ...