Unity中内嵌网页插件UniWebView
一、常见Unity中内嵌网页实现方式:
1、UnityWebCore只支持windows
2、Unity-Webview支持Android,IOS
3、UniWebView支持mac os,Android,IOS,WP8(2.0以后)
二、UniWebView 根据手机平台调用相应的WebView组件来显示网页,支持和javascript的交互,不支持windows和editor上显示。
1、下载并导入unitypackage
http://uniwebview.onevcat.com/
2、设置Webview,加载并显示网页
// Find the UniWebView component on the gameObject.
// It is supposed you have already dragged this script to the same gameObject which UniWebView on.
// Or you will get a null exception :(
_webView = GetComponent<UniWebView>(); // Listen to some event of UniWebView
_webView.OnLoadComplete += OnLoadComplete;
_webView.OnReceivedMessage += OnReceivedMessage;
_webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished;
// Almost full screen but 5 points gap in each edge.
_webView.insets = new UniWebViewEdgeInsets(,,,);
// Set a url string to load
_webView.url = "http://uniwebview.onevcat.com/demo/index.html";
// Tell the web view begin to load the url just set.
_webView.Load(); // Then wait for the OnLoadComplete event //... // The listening method of OnLoadComplete method.
void OnLoadComplete(UniWebView webView, bool success, string errorMessage) {
if (success) {
// Great, everything goes well. Show the web view now.
webView.Show();
} else {
// Oops, something wrong.
Debug.LogError("Something wrong in web view loading: " + errorMessage);
}
}
3、网址解析
uniwebview://move?direction=up&distance=1会解析成
path = "move"
args = {
direction = "up",
distance = ""
}
4、监听消息
void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) {
Debug.Log(message.rawMessage);
if (string.Equals(message.path, "move")) {
// It is time to move! // In this example:
// message.args["direction"] = "up"
// message.args["distance"] = "1"
}
}
详细使用方法参考:http://uniwebview.onevcat.com/manual
Unity中内嵌网页插件UniWebView的更多相关文章
- Unity中内嵌网页插件UniWebView使用总结
目前有三种方式可以实现在Unity工程中实现内嵌网页的功能: 1. UnityWebCore:只支持Windows平台,调用浏览器内核,将网页渲染到mesh,作为gameObject. 2. Un ...
- Unity 内嵌网页
uniwebview 官网 http://uniwebview.onevcat.com/reference/class_uni_web_view.html http://uniwebview.onev ...
- 关于Unity程序在IOS和Android上显示内嵌网页的方式
近期因为有须要在Unity程序执行在ios或android手机上显示内嵌网页.所以遍从网上搜集了一下相关的资料.整理例如以下: UnityWebCore 从搜索中先看到了这个.下载下来了以后发现这个的 ...
- WPF应用程序内嵌网页
原文:WPF应用程序内嵌网页 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/shaynerain/article/details/78160984 WPF ...
- WPF内嵌网页的两种方式
在wpf程序中,有时会内嵌网页.内嵌网页有两种方法,一种是使用wpf自带WebBrowser控件来调用IE内核,另一种是使用CefSharp包来调用chrom内核. 一.第一种使用自带WebBrows ...
- Qt和JavaScript使用QWebChannel交互一——和Qt内嵌网页交互
Qt和JavaScript使用QWebChannel交互一--和Qt内嵌网页交互 目录 Qt和JavaScript使用QWebChannel交互一--和Qt内嵌网页交互 前言 一.效果 二.实现过程 ...
- iOS 之 内嵌网页
现在iOS 有两种内嵌网页的技术,一种是UIWebView,而另一种WKWebView则是iOS8之后出现的技术. iOS 之 UIWebView WKWebView
- [小程序开发] 微信小程序内嵌网页web-view开发教程
为了便于开发者灵活配置小程序,微信小程序开放了内嵌网页能力.这意味着小程序的内容不再局限于pages和large,我们可以借助内嵌网页丰富小程序的内容.下面附上详细的开发教程(含视频操作以及注意事项) ...
- APP中内嵌H5页面为什么不能下载?
在APP中内嵌H5页面,若页面上存在下载链接,没有任何反应,为什么呢? 原因是app中内嵌的H5页面是WebView解析的,什么是WebView呢? 在Android手机中内置了一款高性能webkit ...
随机推荐
- select2下拉插件
下拉单选: 1.行内 1)初始化数据: <select class="form-control select5"> <option selected>张三1 ...
- Java对象的创建及使用
Java对象的创建及使用 对象是类的具体实例(instance),是真实存在的个体:
- stress工具使用指南和结果分析
stress介绍 #stress `stress' imposes certain types of compute stress on your system Usage: stress [OPTI ...
- c3p0 连接池配置
C3P0 可使用properties 配置文件方式,将c3p0.properties放在classpath目录下,如果为WEB应用,放在WEB-INF\classes下 c3p0.properties ...
- Windows环境下flask+Apache+mod_wsgi部署及爬坑
文章目录 安装python Windows 环境使用virtualenv和virtualenvwrapper 安装mod_wsgi 安装nginx 安装Apache 遇到的坑 安装Apache遇到的坑 ...
- 【Codeforces Global Round 1 E】Magic Stones
[链接] 我是链接,点我呀:) [题意] 你可以把c[i]改成c[i+1]+c[i-1]-c[i] (2<=i<=n-1) 问你能不能把每一个c[i]都换成对应的t[i]; [题解] d[ ...
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 G. Xor
There is a tree with nn nodes. For each node, there is an integer value a_iai, (1 \le a_i \le 1,0 ...
- Likecloud-吃、吃、吃(洛谷 1508)
题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢:挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中.某日上课,正当他饿得头昏 ...
- N天学习一个linux命令之xargs
用途 标准输入流读取参数(空格或者换行符分隔),传递给需要执行的命令 用法 xargs [options] [command [initial-arguments]] 常用选项 --arg-file= ...
- jsencrypt代码分析
jsencrypt代码分析——openssl的rsa加密解密在js的实现 在js上做rsa,感觉jsencrypt这个是封装的比较好的,但用起来还是遇到了些坑,所以踩进代码里填填坑- 项目在这里 ...