html->unity3d
html
注意
colorCube
为游戏对象名称RedMe
为脚本中的函数名
unityInstance.SendMessage('colorCube', 'RedMe');
unity3d配置
脚本代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChangeMat : MonoBehaviour
{
public Material redMat;
public Material blueMat;
public void RedMe()
{
// 你的集成代码
}
}
unity3d->html
脚本代码1
注意事件名称HelloString
根据需要进行修改
mergeInto(LibraryManager.library, {
HelloString: function (str) {
ReactUnityWebGL.HelloString(Pointer_stringify(str));
},
});
脚本代码2
事件名 | 事件参数 |
---|---|
HelloString |
This is a string. |
using UnityEngine;
using System.Runtime.InteropServices;
public class NewBehaviourScript : MonoBehaviour {
[DllImport("__Internal")]
private static extern void HelloString(string str);
void Start() {
HelloString("This is a string.");
}
}
暂无数据