当前位置: 首页 > article >正文

Unity WebGL ios 跳转URL

需求:

WebGL跳转网址

现象:

Application.OpenURL("https://www.baidu.com");

这个函数在安卓上可以用,IOS 不管用

解决方案:

编写js插件,unity调用js函数,由js跳转网址 

注意事项 :

插件后缀为.jslib ,并且放到Unity工程Plugins文件夹下

C#代码加上[DllImport]

    public void OpenURL()
    {
        JSOpenURL();
    }

    [DllImport("__Internal")]
    public static extern void JSOpenURL();
mergeInto(LibraryManager.library, {

  JSOpenURL: function () {
    //window.open("https://www.baidu.com");
    location.href = "https://www.baidu.com";
  },

  HelloString: function (str) {
    window.alert(Pointer_stringify(str));
  },

  PrintFloatArray: function (array, size) {
    for(var i = 0; i < size; i++)
    console.log(HEAPF32[(array >> 2) + i]);
  },

  AddNumbers: function (x, y) {
    return x + y;
  },

  StringReturnValueFunction: function () {
    var returnStr = "bla";
    var bufferSize = lengthBytesUTF8(returnStr) + 1;
    var buffer = _malloc(bufferSize);
    stringToUTF8(returnStr, buffer, bufferSize);
    return buffer;
  },

  BindWebGLTexture: function (texture) {
    GLctx.bindTexture(GLctx.TEXTURE_2D, GL.textures[texture]);
  },

});

高级跳转功能:

如跳转各大应用商店,唤醒APP等,暂时不写,催我就写,哈哈

IOSAppStore:

itms-apps://itunes.apple.com/us/developer/<short name>/id<your developer id> 

帮助链接:

官方文档

https://docs.unity3d.com/2021.1/Documentation/Manual/webgl-interactingwithbrowserscripting.html

JS页面跳转常用函数

https://share.ciyuanpi.cn/UnityWebGL/index.html?nickname=jiangbo&url=&avatarAssetName=wukong_t-pose&ismanghe=true


http://www.kler.cn/a/271397.html

相关文章:

  • 鸿蒙Harmony应用开发—ArkTS声明式开发(基础手势:Web)下篇
  • macOS系统中通过brew安装MongoDB
  • 服务器机器学习环境搭建(包括AanConda的安装和Pytorch的安装)
  • [数据集][目标检测]零售柜零食检测数据集VOC+YOLO格式5422张113类
  • xcode15,个推推送SDK闪退问题处理办法
  • idea找不到或无法加载主类
  • (done) NLP “bag-of-words“ 方法 (带有二元分类和多元分类两个例子)词袋模型、BoW
  • JUnit 面试题及答案整理,最新面试题
  • ClickHouse:一款高效且强大的列式数据库管理系统
  • 用 Visual Studio 调试器中查看内存中图像
  • python 爬取人民新闻
  • Godot 学习笔记(1):环境配置
  • 面相对象基础
  • QT进阶---------pro项目文件中的常用命令 (第三天)
  • 计算机设计大赛 题目:基于机器视觉opencv的手势检测 手势识别 算法 - 深度学习 卷积神经网络 opencv python
  • 个人网站制作 Part 9 添加发布、管理博客功能 | Web开发项目
  • 树状数组学习
  • ADO .Net操作SQL Server数据库
  • lime,一个超级厉害的 Python 库!
  • 第八阶段:uni-app小程序 --首页开发(2)