Skip to content

Commit 136e21f

Browse files
committed
docs, textinput method fix
1 parent 4f1a489 commit 136e21f

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Spin up Node dev server:
1717
npm run serve
1818
```
1919

20-
2120
## Directory Structure
2221

2322
`./public/Build` && `./public/TemplateData` - the templates/JS functions of a bare Unity3D WebGL project.
@@ -33,7 +32,14 @@ Text can be sent to the text object in the Unity game instance via the `@click`
3332
this.$refs.myInstance.message('Text', 'SetText', this.textInput)
3433
```
3534

35+
Note: Further configuration is needed to make the text input in `./src/views/Home.vue` editable after the Unity game loads,
36+
since the Unity WebGL instance grabs all keyboard input to the page. There is an example string in the input box for this reason.
37+
38+
[Related Unity forum thread](https://forum.unity.com/threads/disable-enable-keyboard-in-runtime-webgl.286557/#post-1892527)
39+
40+
## Trigger a webpage JavaScript function from Unity Scene
3641

42+
[WIP]
3743

3844
## Project setup
3945
```

src/views/Home.vue

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
<template>
22
<div class="">
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>
14-
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>
3+
<div class="">
4+
<!--
5+
The Unity Container.
6+
Look in the src of npm-modules/vue-unity/webgl/ after npm installing for the mechanics of this custom component
7+
-->
8+
<unity
9+
src="/Build/WebGL-Test.json"
10+
width="1000"
11+
height="600"
12+
unityLoader="/Build/UnityLoader.js" ref="myInstance"
13+
>
14+
</unity>
15+
</div>
16+
<div class="">
17+
<!-- Unstyled text input + button -->
18+
<input v-model="textInput" placeholder="Enter a string to send to Unity">
19+
<button @click="sendText">
20+
Send a string to Unity
21+
</button>
22+
</div>
2023
</div>
2124
</template>
2225
<script>
@@ -29,11 +32,12 @@ export default {
2932
},
3033
data() {
3134
return {
32-
textInput: ''
35+
textInput: "String to send"
3336
}
3437
},
3538
methods: {
3639
sendText() {
40+
console.log(this.textInput)
3741
this.$refs.myInstance.message('Text', 'SetText', this.textInput)
3842
}
3943
}

0 commit comments

Comments
 (0)