一、常见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的更多相关文章

  1. Unity中内嵌网页插件UniWebView使用总结

    目前有三种方式可以实现在Unity工程中实现内嵌网页的功能: 1.  UnityWebCore:只支持Windows平台,调用浏览器内核,将网页渲染到mesh,作为gameObject. 2.  Un ...

  2. Unity 内嵌网页

    uniwebview 官网 http://uniwebview.onevcat.com/reference/class_uni_web_view.html http://uniwebview.onev ...

  3. 关于Unity程序在IOS和Android上显示内嵌网页的方式

    近期因为有须要在Unity程序执行在ios或android手机上显示内嵌网页.所以遍从网上搜集了一下相关的资料.整理例如以下: UnityWebCore 从搜索中先看到了这个.下载下来了以后发现这个的 ...

  4. WPF应用程序内嵌网页

    原文:WPF应用程序内嵌网页 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/shaynerain/article/details/78160984 WPF ...

  5. WPF内嵌网页的两种方式

    在wpf程序中,有时会内嵌网页.内嵌网页有两种方法,一种是使用wpf自带WebBrowser控件来调用IE内核,另一种是使用CefSharp包来调用chrom内核. 一.第一种使用自带WebBrows ...

  6. Qt和JavaScript使用QWebChannel交互一——和Qt内嵌网页交互

    Qt和JavaScript使用QWebChannel交互一--和Qt内嵌网页交互 目录 Qt和JavaScript使用QWebChannel交互一--和Qt内嵌网页交互 前言 一.效果 二.实现过程 ...

  7. iOS 之 内嵌网页

    现在iOS 有两种内嵌网页的技术,一种是UIWebView,而另一种WKWebView则是iOS8之后出现的技术. iOS 之 UIWebView WKWebView

  8. [小程序开发] 微信小程序内嵌网页web-view开发教程

    为了便于开发者灵活配置小程序,微信小程序开放了内嵌网页能力.这意味着小程序的内容不再局限于pages和large,我们可以借助内嵌网页丰富小程序的内容.下面附上详细的开发教程(含视频操作以及注意事项) ...

  9. APP中内嵌H5页面为什么不能下载?

    在APP中内嵌H5页面,若页面上存在下载链接,没有任何反应,为什么呢? 原因是app中内嵌的H5页面是WebView解析的,什么是WebView呢? 在Android手机中内置了一款高性能webkit ...

随机推荐

  1. 在centos安装 sql server

    主要参考官方文档https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-red-hat

  2. 小白年薪24万,为什么Linux运维工程师薪资这么高?

    借了云计算的东风,Linux岗位这几年是越来越火,特别是Linux云计算运维工程师,如今早已成为互联网的核心岗位之一,薪资待遇飞快的上涨. 作为一个细分的专业岗位,Linux云计算工程师由于其入门学习 ...

  3. Nginx +tomcat 实现负载均衡集群

    一.       工具   nginx-1.8.0 apache-tomcat-6.0.33 二.    目标   实现高性能负载均衡的Tomcat集群: 三.    步骤   1.首先下载Nginx ...

  4. react typescript 子组件调用父组件

    //父组件 import * as React from 'react'import { Input } from 'antd'const Search = Input.Searchimport &q ...

  5. 小程序map地图多点定位

    最近需求有一个类似共享单车查看附近单车的功能,看了看小程序map api对多点定位显示描述的不怎么清晰.显示定位数组添加多个时就不显示了.踩了几个坑写了几个方法.最终弄出来了.有问题建议欢迎留言. h ...

  6. CentOS7.2下安装php加速软件Xcache

    说明: php安装目录:/usr/local/php php.ini配置文件路径:/usr/local/php/etc/php.ini Nginx安装目录:/usr/local/nginx Nginx ...

  7. defer, panic, recover使用总结

    1. defer : 延迟调用.多个defer,依次入栈,在函数即将退出时,依次出栈调用 package main import "fmt" func main() { defer ...

  8. hadoop在线重启namenode+在线扩展集群

    1.执行步骤 修改dfs.namenode.handler.count=150 () NameNode 有一个工作线程池用来处理客户端的远程过程调用及集群守护进程的调用.处理程序数量越多意味着要更大的 ...

  9. 【POJ 1860】Currency Exchange

    [题目链接]:http://poj.org/problem?id=1860 [题意] 给你n种货币,m种货币之间的交换信息; 交换信息以 A,B,RA,CA,RB,CB的形式给出; 即A换B的话假设A ...

  10. elasticsearch match和match_phrase匹配原则(十)

    分词测试 分词后倒排索引结果:可以通过http://127.0.0.1:9200/_analyze 测试 { "analyzer":"ik_max_word", ...