Skip to content

Commit 0fadef3

Browse files
authored
refactor: Rename create to render (#41)
* refactor: Rename create to render * docs: Update README
1 parent 786885f commit 0fadef3

File tree

6 files changed

+89
-88
lines changed

6 files changed

+89
-88
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
`unity-webgl` provides an easy solution for embedding `Unity WebGL` builds in your web applications, with two-way communication and interaction between your webApp and Unity application with advanced API's.
1313

1414
> 🚨 Reminder
15-
>
15+
>
1616
> `v4.x` has been updated significantly and the API is not compatible with `v3.x` and earlier versions. For upgrades, please refer to [Changelogs](https://github.com/Marinerer/unity-webgl/wiki/Major-changes-in-v4)
1717
1818
Based on [react-unity-webgl](https://github.com/jeffreylanters/react-unity-webgl)
@@ -22,7 +22,7 @@ Based on [react-unity-webgl](https://github.com/jeffreylanters/react-unity-webgl
2222
- 📦 Easy integration, framework-agnostic
2323
- 📩 Bidirectional communication between WebApp and Unity
2424
- ⏰ Comprehensive event handling mechanism
25-
- 🧲 Built-in Vue components (vue2/3)
25+
- 🧲 Built-in Vue components (`vue2/3`)
2626

2727
## Installation
2828

@@ -44,7 +44,7 @@ npm install unity-webgl
4444
- [vue3 Demo](https://stackblitz.com/edit/unity-webgl-v4-vue3-demo)
4545

4646
> 🚨 **Important:**
47-
> Communication and interaction with the web application are only possible after the Unity instance is successfully created (when the `mounted` event is triggered).
47+
> Communication and interaction with the web application are only possible after the Unity instance is successfully rendered (when the `mounted` event is triggered).
4848
> Recommended to include a loading progress bar when opening the page.
4949
5050
```javascript
@@ -60,7 +60,7 @@ const unityContext = new UnityWebgl('#canvas', {
6060
unityContext
6161
.on('progress', (progress) => console.log('Loaded: ', progress))
6262
.on('mounted', () => {
63-
// ⚠️ Unity instance created, ready for communication
63+
// ⚠️ UnityInstance rendered, ready for communication
6464
unityContext.sendMessage('GameObject', 'ReceiveRole', 'Tanya')
6565
})
6666

@@ -108,7 +108,7 @@ new UnityWebgl(canvas: HTMLCanvasElement | string, config?:UnityConfig)
108108
// or
109109

110110
const unityContext = new UnityWebgl(config: UnityConfig)
111-
unityContext.create(canvas: HTMLCanvasElement | string)
111+
unityContext.render(canvas: HTMLCanvasElement | string)
112112
```
113113

114114
- `canvas` : Render Unity canvas elements or selectors.
@@ -120,10 +120,10 @@ Initializes the Unity application's configuration items.
120120

121121
| Property | Type | Description | Required |
122122
| ------------------------ | ------- | -------------------------------------------------------------------------------------------------- | -------- |
123-
| `loaderUrl` | string | Unity resource loader file | |
124-
| `dataUrl` | string | File containing resource data and scenes | |
125-
| `frameworkUrl` | string | File with runtime and plugin code | |
126-
| `codeUrl` | string | WebAssembly binary file with native code | |
123+
| `loaderUrl` | string | Unity resource loader file ||
124+
| `dataUrl` | string | File containing resource data and scenes ||
125+
| `frameworkUrl` | string | File with runtime and plugin code ||
126+
| `codeUrl` | string | WebAssembly binary file with native code ||
127127
| `streamingAssetsUrl` | string | URL for streaming resources | Optional |
128128
| `memoryUrl` | string | URL for generated framework files | Optional |
129129
| `symbolsUrl` | string | URL for generated Unity code files | Optional |
@@ -142,14 +142,14 @@ Initializes the Unity application's configuration items.
142142

143143
**Instance methods :**
144144

145-
#### ⭐️ `create(canvas: HTMLCanvasElement | string): void;`
145+
#### ⭐️ `render(canvas: HTMLCanvasElement | string): void;`
146146

147-
Create a Unity WebGL instance on the specified canvas.
147+
Renders UnityInstance into target html canvas element.
148148

149149
- `canvas` : canvas element
150150

151151
```javascript
152-
await unityContext.create('#canvas')
152+
await unityContext.render('#canvas')
153153
```
154154

155155
#### ⭐️ `unload(): Promise<void>;`
@@ -248,15 +248,15 @@ window.dispatchUnityEvent('GameStarted', 3)
248248

249249
### Events
250250

251-
| Event Name | Description |
252-
| --------------- | ---------------------------------------- |
253-
| `beforeMount` | Triggered before Unity instance creation |
254-
| `mounted` | Triggered after Unity instance creation |
255-
| `beforeUnmount` | Triggered before Unity instance unload |
256-
| `unmounted` | Triggered after Unity instance unload |
257-
| `progress` | Unity resource loading progress |
258-
| `error` | Error events |
259-
| `debug` | Debug messages from Unity |
251+
| Event Name | Description |
252+
| --------------- | ------------------------------------------------- |
253+
| `beforeMount` | Before rendering UnityInstance to Canvas Element. |
254+
| `mounted` | After rendering UnityInstance to Canvas Element. |
255+
| `beforeUnmount` | Before UnityInstance unload |
256+
| `unmounted` | After UnityInstance unload |
257+
| `progress` | Unity resource loading progress |
258+
| `error` | Error events |
259+
| `debug` | Debug messages from Unity |
260260

261261
## Unity-JavaScript Communication
262262

README.zh_CN.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
`unity-webgl` 提供了一个简单的解决方案,用于将 `Unity WebGL` 构建嵌入到 Web 应用程序中,同时为 Unity 和 WebApp 应用之间的双向通信和交互提供 API。
1313

1414
> 🚨 提醒
15-
>
15+
>
1616
> `v4.x` 版本进行了较大更新,API 不兼容 `v3.x`及之前版本。升级请参考 [变更信息](https://github.com/Marinerer/unity-webgl/wiki/Major-changes-in-v4)
1717
18-
1918
Based on [react-unity-webgl](https://github.com/jeffreylanters/react-unity-webgl)
2019

2120
## Features
@@ -45,7 +44,7 @@ https://cdn.jsdelivr.net/npm/unity-webgl/dist/index.min.js
4544
- [vue3 Demo](https://stackblitz.com/edit/unity-webgl-v4-vue3-demo)
4645

4746
> 🚨 提醒:
48-
> 仅在 `Unity` 实例成功创建后(触发 `mounted` 事件时)才能进行 Web 应用程序的通信和交互。
47+
> 仅在 `UnityInstance` 渲染完成后(触发 `mounted` 事件时)才能进行 Web 应用程序的通信和交互。
4948
> 建议在页面打开时添加加载进度条。
5049
5150
```javascript
@@ -61,7 +60,7 @@ const unityContext = new UnityWebgl('#canvas', {
6160
unityContext
6261
.on('progress', (progress) => console.log('Loaded: ', progress))
6362
.on('mounted', () => {
64-
// ⚠️ unity实例已创建,可与unity侧进行通信
63+
// ⚠️ UnityInstance 已创建,可与unity侧进行通信
6564
unityContext.sendMessage('GameObject', 'ReceiveRole', 'Tanya')
6665
})
6766

@@ -109,7 +108,7 @@ new UnityWebgl(canvas: HTMLCanvasElement | string, config?:UnityConfig)
109108
// or
110109

111110
const unityContext = new UnityWebgl(config: UnityConfig)
112-
unityContext.create(canvas: HTMLCanvasElement | string)
111+
unityContext.render(canvas: HTMLCanvasElement | string)
113112
```
114113

115114
- `canvas` : 渲染Unity的画布元素或选择器。
@@ -121,10 +120,10 @@ unityContext.create(canvas: HTMLCanvasElement | string)
121120

122121
| Property | Type | Description | Required |
123122
| ------------------------ | ------- | ------------------------------------------------------------------------------------- | -------- |
124-
| `loaderUrl` | string | Unity 资源加载器文件 | |
125-
| `dataUrl` | string | 包含资源数据和场景的文件 | |
126-
| `frameworkUrl` | string | 包含运行时和插件代码的文件 | |
127-
| `codeUrl` | string | 包含原生代码的 WebAssembly 二进制文件 | |
123+
| `loaderUrl` | string | Unity 资源加载器文件 ||
124+
| `dataUrl` | string | 包含资源数据和场景的文件 ||
125+
| `frameworkUrl` | string | 包含运行时和插件代码的文件 ||
126+
| `codeUrl` | string | 包含原生代码的 WebAssembly 二进制文件 ||
128127
| `streamingAssetsUrl` | string | 流媒体资源的 URL | 可选 |
129128
| `memoryUrl` | string | 生成的框架文件的 URL | 可选 |
130129
| `symbolsUrl` | string | 生成的 Unity 代码文件的 URL | 可选 |
@@ -143,14 +142,14 @@ unityContext.create(canvas: HTMLCanvasElement | string)
143142

144143
**Instance methods :**
145144

146-
#### ⭐️ `create(canvas: HTMLCanvasElement | string): void;`
145+
#### ⭐️ `render(canvas: HTMLCanvasElement | string): void;`
147146

148-
在指定画布上创建 Unity WebGL 实例
147+
在指定画布上渲染 Unity WebGL 实例资源
149148

150149
- `canvas` : canvas画布元素
151150

152151
```javascript
153-
await unityContext.create('#canvas')
152+
await unityContext.render('#canvas')
154153
```
155154

156155
#### ⭐️ `unload(): Promise<void>;`
@@ -253,10 +252,10 @@ Unity 实例从创建到销毁过程中触发的事件。
253252

254253
| event name | description |
255254
| ----------------------------- | ----------------------- |
256-
| `beforeMount(unityContext)` | 创建 Unity 实例之前触发 |
257-
| `mounted(unityContext)` | 创建 Unity 实例后触发 |
258-
| `beforeUnmount(unityContext)` | 卸载 Unity 实例之前触发 |
259-
| `unmounted()` | 卸载 Unity 实例后触发 |
255+
| `beforeMount(unityContext)` | 渲染 Unity 实例资源之前 |
256+
| `mounted(unityContext)` | 渲染 Unity 实例资源之后 |
257+
| `beforeUnmount(unityContext)` | 卸载 Unity 实例资源之前 |
258+
| `unmounted()` | 卸载 Unity 实例资源之后 |
260259
| `progress(val: number)` | unity 资源加载进度更新 |
261260
| `error(err: Event\|string)` | 发生错误 |
262261
| `debug(msg: string)` | 来自 Unity 的调试消息 |
@@ -332,11 +331,9 @@ public class WebGLPluginJS : MonoBehaviour
332331
- [调试 WebGL 构建并排除故障](https://docs.unity3d.com/cn/2023.2/Manual/webgl-debugging.html)
333332
- [WebGL 性能考虑因素](https://docs.unity3d.com/cn/2023.2/Manual/webgl-performance.html)
334333

335-
336-
337334
## License
338335

339-
MIT License
336+
Apache-2.0 License
340337

341338
## Contributing
342339

lib/components/src/vue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineComponent({
5353

5454
onMounted(() => {
5555
if (canvas.value) {
56-
props.unity?.create(canvas.value)
56+
props.unity?.render(canvas.value)
5757
}
5858
})
5959
onBeforeUnmount(() => {

lib/core/README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
`unity-webgl` provides an easy solution for embedding `Unity WebGL` builds in your web applications, with two-way communication and interaction between your webApp and Unity application with advanced API's.
1313

1414
> 🚨 Reminder
15-
>
15+
>
1616
> `v4.x` has been updated significantly and the API is not compatible with `v3.x` and earlier versions. For upgrades, please refer to [Changelogs](https://github.com/Marinerer/unity-webgl/wiki/Major-changes-in-v4)
1717
1818
Based on [react-unity-webgl](https://github.com/jeffreylanters/react-unity-webgl)
@@ -22,7 +22,7 @@ Based on [react-unity-webgl](https://github.com/jeffreylanters/react-unity-webgl
2222
- 📦 Easy integration, framework-agnostic
2323
- 📩 Bidirectional communication between WebApp and Unity
2424
- ⏰ Comprehensive event handling mechanism
25-
- 🧲 Built-in Vue components (vue2/3)
25+
- 🧲 Built-in Vue components (`vue2/3`)
2626

2727
## Installation
2828

@@ -44,7 +44,7 @@ npm install unity-webgl
4444
- [vue3 Demo](https://stackblitz.com/edit/unity-webgl-v4-vue3-demo)
4545

4646
> 🚨 **Important:**
47-
> Communication and interaction with the web application are only possible after the Unity instance is successfully created (when the `mounted` event is triggered).
47+
> Communication and interaction with the web application are only possible after the Unity instance is successfully rendered (when the `mounted` event is triggered).
4848
> Recommended to include a loading progress bar when opening the page.
4949
5050
```javascript
@@ -60,7 +60,7 @@ const unityContext = new UnityWebgl('#canvas', {
6060
unityContext
6161
.on('progress', (progress) => console.log('Loaded: ', progress))
6262
.on('mounted', () => {
63-
// ⚠️ Unity instance created, ready for communication
63+
// ⚠️ UnityInstance rendered, ready for communication
6464
unityContext.sendMessage('GameObject', 'ReceiveRole', 'Tanya')
6565
})
6666

@@ -108,7 +108,7 @@ new UnityWebgl(canvas: HTMLCanvasElement | string, config?:UnityConfig)
108108
// or
109109

110110
const unityContext = new UnityWebgl(config: UnityConfig)
111-
unityContext.create(canvas: HTMLCanvasElement | string)
111+
unityContext.render(canvas: HTMLCanvasElement | string)
112112
```
113113

114114
- `canvas` : Render Unity canvas elements or selectors.
@@ -120,10 +120,10 @@ Initializes the Unity application's configuration items.
120120

121121
| Property | Type | Description | Required |
122122
| ------------------------ | ------- | -------------------------------------------------------------------------------------------------- | -------- |
123-
| `loaderUrl` | string | Unity resource loader file | |
124-
| `dataUrl` | string | File containing resource data and scenes | |
125-
| `frameworkUrl` | string | File with runtime and plugin code | |
126-
| `codeUrl` | string | WebAssembly binary file with native code | |
123+
| `loaderUrl` | string | Unity resource loader file ||
124+
| `dataUrl` | string | File containing resource data and scenes ||
125+
| `frameworkUrl` | string | File with runtime and plugin code ||
126+
| `codeUrl` | string | WebAssembly binary file with native code ||
127127
| `streamingAssetsUrl` | string | URL for streaming resources | Optional |
128128
| `memoryUrl` | string | URL for generated framework files | Optional |
129129
| `symbolsUrl` | string | URL for generated Unity code files | Optional |
@@ -142,14 +142,14 @@ Initializes the Unity application's configuration items.
142142

143143
**Instance methods :**
144144

145-
#### ⭐️ `create(canvas: HTMLCanvasElement | string): void;`
145+
#### ⭐️ `render(canvas: HTMLCanvasElement | string): void;`
146146

147-
Create a Unity WebGL instance on the specified canvas.
147+
Renders UnityInstance into target html canvas element.
148148

149149
- `canvas` : canvas element
150150

151151
```javascript
152-
await unityContext.create('#canvas')
152+
await unityContext.render('#canvas')
153153
```
154154

155155
#### ⭐️ `unload(): Promise<void>;`
@@ -248,15 +248,15 @@ window.dispatchUnityEvent('GameStarted', 3)
248248

249249
### Events
250250

251-
| Event Name | Description |
252-
| --------------- | ---------------------------------------- |
253-
| `beforeMount` | Triggered before Unity instance creation |
254-
| `mounted` | Triggered after Unity instance creation |
255-
| `beforeUnmount` | Triggered before Unity instance unload |
256-
| `unmounted` | Triggered after Unity instance unload |
257-
| `progress` | Unity resource loading progress |
258-
| `error` | Error events |
259-
| `debug` | Debug messages from Unity |
251+
| Event Name | Description |
252+
| --------------- | ------------------------------------------------- |
253+
| `beforeMount` | Before rendering UnityInstance to Canvas Element. |
254+
| `mounted` | After rendering UnityInstance to Canvas Element. |
255+
| `beforeUnmount` | Before UnityInstance unload |
256+
| `unmounted` | After UnityInstance unload |
257+
| `progress` | Unity resource loading progress |
258+
| `error` | Error events |
259+
| `debug` | Debug messages from Unity |
260260

261261
## Unity-JavaScript Communication
262262

0 commit comments

Comments
 (0)