# unity-cloudrendering-sdk

> ## 安装前准备 - 上传应用至[Unity云渲染平台](https://cloudrendering.unity.cn) - 生成分享链接，获取分享链接的唯一id https://cloudrendering.unity.cn/share/{shareKey}

Latest version **0.0.9** (published 2023-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install unity-cloudrendering-sdk
pnpm add unity-cloudrendering-sdk
yarn add unity-cloudrendering-sdk
bun add unity-cloudrendering-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2023-05-29 |
| First published | 2022-09-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tedge_unity |

## Links

- npm: https://www.npmjs.com/package/unity-cloudrendering-sdk
- npm.io page: https://npm.io/package/unity-cloudrendering-sdk

## Recent versions

- 0.0.9 (latest) — 2023-05-29
- 0.0.8 — 2023-05-08
- 0.0.6 — 2022-09-20
- 0.0.5 — 2022-09-20
- 0.0.4 — 2022-09-20
- 0.0.3 — 2022-09-20
- 0.0.2 — 2022-09-20
- 0.0.1 — 2022-09-19

## README

# [Unity云渲染](https://cloudrendering.unity.cn) Javascript SDK

## 安装前准备
- 上传应用至[Unity云渲染平台](https://cloudrendering.unity.cn)
- 生成分享链接，获取分享链接的唯一id https://cloudrendering.unity.cn/share/{shareKey}

## 安装sdk
```
npm install --save unity-cloudrendering-sdk
```

## 使用参考

### web端代码示例
```javascript
    
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端代码示例
```C#
using UnityEngine;

// 向浏览器端（JS SDK）发送消息
CloudStreaming.PostMessage("Hello Cloud Rendering");

// 接受浏览器端（JS SDK）发送来的消息
var sdkMessage = CloudStreaming.PeekMessage(); // 返回值为string类型
```

---
_Source: https://npm.io/package/unity-cloudrendering-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
