unity-cloudrendering-sdk
v0.0.9
Published
## 安装前准备 - 上传应用至[Unity云渲染平台](https://cloudrendering.unity.cn) - 生成分享链接,获取分享链接的唯一id https://cloudrendering.unity.cn/share/{shareKey}
Downloads
32
Readme
Unity云渲染 Javascript SDK
安装前准备
- 上传应用至Unity云渲染平台
- 生成分享链接,获取分享链接的唯一id https://cloudrendering.unity.cn/share/{shareKey}
安装sdk
npm install --save unity-cloudrendering-sdk
使用参考
web端代码示例
const { Player, UGP_SDK_EVENTS } = require("unity-cloudrendering-sdk");
// 在网页的streaming-div节点下嵌入云渲染模块,分享id为02268d0fe356ef31
const player = new Player("02268d0fe356ef31" ,"streaming-div");
// 绑定LOADED事件
player.bind(UGP_SDK_EVENTS.LOADED, (msg) => {
console.log('streaming loaded');
})
// 绑定UGP_MESSAGE事件
player.bind(UGP_SDK_EVENTS.UGP_MESSAGE, (msg) => {
console.log('receive message from remote');
})
// 从浏览器端发送自定义消息至
const sendBtn = document.getElementById("send-btn");
sendBtn.onclick = () => {
player.postMessage('Hello Cloud Rendering');
};
unity端代码示例
using UnityEngine;
// 向浏览器端(JS SDK)发送消息
CloudStreaming.PostMessage("Hello Cloud Rendering");
// 接受浏览器端(JS SDK)发送来的消息
var sdkMessage = CloudStreaming.PeekMessage(); // 返回值为string类型