unity-webgl
Advanced tools
Comparing version
/*! | ||
* unity-webgl.js v3.0.0-beta.4 | ||
* unity-webgl.js v3.0.0 | ||
* (c) 2022 Mervin<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* unity-webgl.js v3.0.0-beta.4 | ||
* unity-webgl.js v3.0.0 | ||
* (c) 2022 Mervin<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
{ | ||
"name": "unity-webgl", | ||
"version": "3.0.0-beta.4", | ||
"version": "3.0.0", | ||
"description": "An easy solution for embedding Unity WebGL builds in your Vue.js or Web Application.", | ||
@@ -39,5 +39,6 @@ "keywords": [ | ||
"scripts": { | ||
"clean": "rimraf -rf ./dist && rimraf -rf ./vue", | ||
"dev": "NODE_ENV=development rollup -c rollup.config.js -w", | ||
"build": "rimraf -rf ./dist && NODE_ENV=production rollup -c rollup.config.js", | ||
"release": "rimraf -rf ./vue && npm run build && node ./scripts/release.js" | ||
"build": "npm run clean && NODE_ENV=production rollup -c rollup.config.js", | ||
"release": "npm run build && node ./scripts/release.js" | ||
}, | ||
@@ -44,0 +45,0 @@ "devDependencies": { |
@@ -13,3 +13,3 @@ # unity-webgl | ||
- 🛠 Built-in event handler | ||
- 🧬 Available for `Vue.js` ([Vue@2.x](https://jake.stackblitz.com/edit/unity-webgl-vue2-demo?file=src%2FApp.vue) & [Vue@3.x](https://stackblitz.com/edit/unity-webgl-vue3-demo?file=src/App.vue)) | ||
- 🧬 Available for `Vue.js` ([Vue@2.x](https://stackblitz.com/edit/unity-webgl-vue2-demo?file=src%2FApp.vue) & [Vue@3.x](https://stackblitz.com/edit/unity-webgl-vue3-demo?file=src%2FApp.vue)) | ||
@@ -28,3 +28,4 @@ ## Install | ||
in example.html: | ||
<details> | ||
<summary>in example.html</summary> | ||
@@ -89,39 +90,71 @@ ```html | ||
``` | ||
</details> | ||
### Vue | ||
* [Vue@2.x example](https://jake.stackblitz.com/edit/unity-webgl-vue2-demo?file=src%2FApp.vue) | ||
* [Vue@2.x example](https://stackblitz.com/edit/unity-webgl-vue2-demo?file=src%2FApp.vue) | ||
* [Vue@3.x example](https://stackblitz.com/edit/unity-webgl-vue3-demo?file=src/App.vue) | ||
in example.vue | ||
<details> | ||
<summary>Vue 2.x</summary> | ||
```html | ||
<template> | ||
<Unity :unity="unityContext" width="800px" height="600px" /> | ||
<VueUnity :unity="unityContext" width="800" heighht="600" /> | ||
</template> | ||
<script> | ||
import UnityWebgl from 'unity-webgl' | ||
import UnityWebgl from 'unity-webgl' | ||
import VueUnity from 'Unity-webgl/vue' | ||
const Unity = new UnityWebgl({ | ||
loaderUrl: '/Build/unity.loader.js', | ||
dataUrl: "/Build/unity.data", | ||
frameworkUrl: "/Build/unity.framework.js", | ||
codeUrl: "/Build/unity.wasm" | ||
}) | ||
const Unity = new UnityWebgl({ | ||
loaderUrl: '/Build/OUT_BIM.loader.js', | ||
dataUrl: "/Build/OUT_BIM.data", | ||
frameworkUrl: "/Build/OUT_BIM.framework.js", | ||
codeUrl: "/Build/OUT_BIM.wasm", | ||
}) | ||
export default { | ||
name: 'Unity', | ||
components: { | ||
Unity: UnityWebgl.vueComponent | ||
}, | ||
data() { | ||
return { | ||
unityContext: Unity | ||
Unity.on('device', () => alert('click device ...')) | ||
export default { | ||
components: { | ||
VueUnity | ||
}, | ||
data() { | ||
return { | ||
unityContext: Unity | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
</details> | ||
<details> | ||
<summary>Vue 3.x</summary> | ||
```html | ||
<script setup lang="ts"> | ||
import UnityWebgl from 'Unity-webgl'; | ||
import VueUnity from 'Unity-webgl/vue' | ||
const Unity = new UnityWebgl({ | ||
loaderUrl: '/Build/OUT_BIM.loader.js', | ||
dataUrl: "/Build/OUT_BIM.data", | ||
frameworkUrl: "/Build/OUT_BIM.framework.js", | ||
codeUrl: "/Build/OUT_BIM.wasm", | ||
}) | ||
Unity.on('device', () => alert('click device ...')) | ||
</script> | ||
<template> | ||
<VueUnity :unity="Unity" width="800" heighht="600" /> | ||
</template> | ||
``` | ||
</details> | ||
## API | ||
@@ -170,3 +203,3 @@ | ||
* `on(eventName: string, eventListener: Function)` | ||
Use `instance.on()` to register a method for Unity-scirpt call. | ||
Use `instance.on()` to register a method for Unity-script call. | ||
* `once(eventName: string, eventListener: Function)` | ||
@@ -180,23 +213,19 @@ * `off(eventName: string)` | ||
- `progress` | ||
* `progress` | ||
loading progress. | ||
```js | ||
unityContext.on('progress', (number) => {}) | ||
``` | ||
- `loaded` | ||
* `loaded` | ||
loading completed. | ||
```js | ||
unityContext.on('loaded', () => {}) | ||
``` | ||
- `created` | ||
* `created` | ||
Unity Instance is created. | ||
```js | ||
unityContext.on('created', () => {}) | ||
``` | ||
- `destroyed` | ||
* `destroyed` | ||
Quits the Unity Instance and clears it from memory. | ||
```js | ||
@@ -211,4 +240,4 @@ unityContext.on('destroyed', () => {}) | ||
* `unity: UnityWebgl` | ||
* `width?: string|number ` , default: `100%` | ||
* `height?: string|number ` , default: `100%` | ||
* `width?: string|number` , default: `100%` | ||
* `height?: string|number` , default: `100%` | ||
@@ -215,0 +244,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
41860
1.61%0
-100%338
9.39%