Skip to content

Commit 72322c1

Browse files
committed
moar docs + comments
1 parent c560beb commit 72322c1

File tree

4 files changed

+33
-57
lines changed

4 files changed

+33
-57
lines changed

README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# Unity Vue Boilerplate
1+
# UnityWebGL VueJS Boilerplate
22

33
This is a boilerplate **Unity WebGL** ++ **VueJS** web app with **VueX && **vue-router** pre-installed.
44

55
This project takes advantage of the Unity3d web container wrapper component provided by
66
@votetake's [vue-unity-webgl](https://github.com/votetake/vue-unity-webgl) Node package.
77

8+
## Directory Structure
89

10+
`./public/Build` && `./public/TemplateData` - the templates/JS functions of a bare Unity3D WebGL project.
11+
12+
## Send a string from VueJS to the Unity Scene
13+
14+
The Unity scene contains only a lean 3D plane and a text object.
15+
16+
Text can be sent to the text object in the Unity game instance via the `@click` method in `./src/views/Home.vue`:
17+
18+
```JavaScript
19+
// $refs.myInstance === <unity ref="myInstance">
20+
this.$refs.myInstance.message('Text', 'SetText', this.textInput)
21+
```
922

1023
## Project setup
1124
```

index.html

-50
This file was deleted.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "unity-vue-boilerplate",
2+
"name": "unity-vuejs-boilerplate",
3+
"author": "Nick West <[email protected]>",
34
"version": "0.1.0",
45
"private": true,
56
"scripts": {

src/views/Home.vue

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
<template>
22
<div class="">
3-
<unity src="/Build/WebGL-Test.json" width="1000" height="600" unityLoader="/Build/UnityLoader.js" ref="myInstance"></unity>
4-
<input type="text" v-model="textInput" description="Input text here to send to Unity">
3+
<!--
4+
The Unity Container.
5+
Look in the src of npm-modules/vue-unity/webgl/ after npm installing for the mechanics of this custom component
6+
-->
7+
<unity
8+
src="/Build/WebGL-Test.json"
9+
width="1000"
10+
height="600"
11+
unityLoader="/Build/UnityLoader.js" ref="myInstance"
12+
>
13+
</unity>
514

6-
<button @click="inputText">My Button >:(</button>
15+
<!-- Unstyled text input + button -->
16+
<input type="text" v-model="textInput" description="Input text here to send to Unity">
17+
<button @click="inputText">
18+
Send a string to Unity
19+
</button>
720
</div>
8-
921
</template>
1022
<script>
1123
import Unity from 'vue-unity-webgl'
@@ -21,7 +33,7 @@ export default {
2133
}
2234
},
2335
methods: {
24-
sendText () {
36+
sendText() {
2537
this.$refs.myInstance.message('Text', 'SetText', this.textInput)
2638
}
2739
}

0 commit comments

Comments
 (0)