• unity3d与web进行交互


    一、unity调用web的js函数

    在unity中写如下调用语句:

    Application.ExternalCall( "SayHello", "The game says hello!" );

    在html中定义函数如下

    function SayHello(args){
        alert(args);
    }

    二、在web中用js调用unity对象函数

    在unity中定义函数如下,并将脚本绑定到名为Interface的GameObject中

    function createOutTask(){
        GameObject.Find("CreateOutTask").GetComponent(CreateOutTask).createOutTask();
    }

    在web中调用unity对象时,需特别注意使用的unity的版本

    3.5及以前版本,调用如下:

    GetUnity().SendMessage("Interface", "createOutTask", "")

    4.0版本,调用如下:

    var config = {
         1730, 
        height: 980,
        params: { enableDebugging:"0", disableContextMenu: true }
        
    };
    var u = new UnityObject2(config);
    
    u.getUnity().SendMessage("Interface", "createOutTask", "");
    对于4.0版本的调用,参照官方文档http://docs.unity3d.com/Documentation/Manual/UnityWebPlayerandbrowsercommunication.html
    Note: keep in mind that if the function doesn't have any arguments, then an empty string ("") should be passed as an argument.
  • 相关阅读:
    通道分离与合并
    opencv颜色表操作
    opencv trackbar
    像素操作
    opencv 像素读写
    py 时间与日期
    py 字典
    py 元组
    py 列表
    课后作业-阅读任务-阅读提问-3
  • 原文地址:https://www.cnblogs.com/huntdream/p/3031629.html
Copyright © 2020-2023  润新知