Git Product home page Git Product logo

ulitewebview's Introduction

「ULiteWebView」使用指南

1.简介

ULiteWebView是一个极度轻量化的Unity内嵌WebView插件

支持的平台:安卓/苹果

功能:

  • 网络浏览
  • 支持Html5
  • 支持Unity与JS自定义接口交互
  • 支持URL SCHEME
  • 可定制的显示窗体大小

特点:

  • 接入简单,核心文件仅3个,且无需额外配置
  • 轻量化,增加代码量仅20KB左右
  • 使用简单,复杂的功能已封装为几个调用简单的API接口

2.项目官网

3.在项目中使用

接入

至官网下载.unitypackage文件后,双击即可导入到项目中。如果不需要DEMO文件,只需要导入下方3个核心文件,插件即可正常使用。

/Assets /Plugins /Android/ULiteWebView.aar /IOS/ULiteWebView.mm /ULiteWevView/ULiteWebView.cs

使用

在场景中任意位置创建GameObject对象,并添加「ULiteWebView.cs」脚本。即可通过API工作

4.API说明

显示WebView

///

/// 显示ULiteWebView关联的WebView /// /// Web�View距离屏幕上边缘的距离(单位:像素) /// Web�View距离屏幕下边缘的距离(单位:像素) /// Web�View距离屏幕左边缘的距离(单位:像素) /// Web�View距离屏幕右边缘的距离(单位:像素) public void Show(int top, int bottom, int left, int right)

加载URL

///

/// 使用WebView加载指定的URL,访问网页用Http://开头 /// /// 访问的URL地址 public void LoadUrl(string url)

加载本地资源

///

/// 访问StreamingAssets文件夹中存放的资源 /// /// 相对于StreamingAssets目录的文件路径,以"/"开头 public void LoadLocal(string filePath)

关闭WebView

///

/// 关闭ULiteWebView关联的WebView /// public void Close()

调用JS

///

/// 请求当前WebView页面中对应的JS方法 /// /// Fun name. /// Message. public void CallJS(string funName, string msg)

注册供JS调用的Unity方法

///

/// 注册供JS调用的方法 /// /// 方法名:JS通过该方法名调用对应方法 /// 方法 public void RegistJsInterfaceAction(string interfaceName, Action action)

注销供JS调用的Unity方法

///

/// 注销供JS调用的方法 /// /// 方法名:JS通过该方法名调用对应方法 /// 方法 public void UnregistJsInterfaceAction(string interfaceName, Action action)

ulitewebview's People

Contributors

jinglikeblue avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.