@silen/unity
v1.0.2
Published
vue unity
Downloads
3
Readme
VueUnity
npm i @silen/unity
Usage
main.js
import Vue from 'vue';
import Unity from '@silen/unity';
Vue.use(Unity);
component
<template>
<Unity
ref="unityRef"
src="./Build/WebglTest.json"
unityLoader="./Build/UnityLoader.js"
:hide-full-button="true"
@loaded="onLoaded"
@progress="onProgress"
></Unity>
</template>
<script>
import Unity from '@silen/unity';
export default {
components: {
Unity
},
methods: {
onLoaded(loaded, instance) {
if (loaded) {
instance.SendMessage('object', 'method', 'param');
}
},
onProgress(progress, instance) {
// 0 <= progress <= 1
console.log(progress, instance);
}
}
}
</script>
loading
You can add a loading component for it.
<template>
<Unity
ref="unityRef"
src="./Build/WebglTest.json"
unityLoader="./Build/UnityLoader.js"
:hide-full-button="true"
@loaded="onLoaded"
@progress="onProgress"
>
<YourLoadingComponent></YourLoadingComponent>
</Unity>
</template>
in browser environment
<!DOCTYPE html>
<html lang="en">
<head>
<title>Unity Example</title>
</head>
<body>
<div id="app"></div>
</body>
<script src="Build/UnityLoader.js"></script>
<script src="./node_modules/unity/dist/index.js"></script>
</html>
instance methods
fullscreen
message
this.$refs.unityRef.fullscreen()
this.$refs.unityRef.message('object', 'method', 'param')