├── .gitignore
├── .npmignore
├── .babelrc
├── src
├── index.js
└── Unity.vue
├── rollup.config.js
├── package.json
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log
5 | yarn-error.log
6 | .idea/
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log
5 | yarn-error.log
6 | .idea/
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "modules": false
7 | }
8 | ]
9 | ]
10 | }
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import unity from './Unity.vue'
2 |
3 | const install = Vue => {
4 | Vue.component('unity', unity)
5 | }
6 |
7 | unity.install = install
8 |
9 | // export const Unity = unity
10 |
11 | export default unity
12 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import vue from 'rollup-plugin-vue';
2 | import babel from 'rollup-plugin-babel';
3 | import resolve from 'rollup-plugin-node-resolve';
4 |
5 | export default {
6 | entry: './src/index.js',
7 | dest: 'vue-unity-webgl.js',
8 | plugins: [
9 | resolve(),
10 | vue({compileTemplate: true}),
11 | babel()
12 | ],
13 | format: 'umd',
14 | name: 'vueUnityWebGL'
15 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-unity-webgl",
3 | "version": "1.2.0",
4 | "description": "Unity WebGL component for VueJs application",
5 | "main": "src/index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/votetake/vue-unity-webgl.git"
12 | },
13 | "keywords": [
14 | "vue",
15 | "unity",
16 | "webgl"
17 | ],
18 | "author": "votetake",
19 | "license": "ISC",
20 | "bugs": {
21 | "url": "https://github.com/votetake/vue-unity-webgl/issues"
22 | },
23 | "homepage": "https://github.com/votetake/vue-unity-webgl#readme",
24 | "dependencies": {
25 | "babel-core": "^6.26.0",
26 | "babel-preset-env": "^1.6.0",
27 | "rollup": "^0.50.0",
28 | "rollup-plugin-babel": "^3.0.2",
29 | "rollup-plugin-node-resolve": "^3.0.0",
30 | "rollup-plugin-vue": "^2.4.2",
31 | "vue": "^2.5.2",
32 | "vue-template-compiler": "^2.5.2"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-unity-webgl
2 |
3 | Easy to use Unity 5.6 or newer (also Unity 2017 or newer) WebGL player component for your VueJS application. Embed your Unity application in your application for writing interactive interfaces with two way Unity and VueJS communication.
4 |
5 |
6 |
7 | ## Install
8 |
9 | ```Bash
10 | npm install vue-unity-webgl
11 | ```
12 |
13 | ## Usage
14 | To get stated import the Unity component from `vue-unity-webgl`. Once imported you can use the Unity component to load in your Unity content. Place the Unity tag along with a src to the json file Unity exported.
15 |
16 | ```js
17 |
18 |
19 |
20 |
21 |
28 | ```
29 | > ### Notice
30 | > Don't forget to add a script tag to load the `UnityLoader.js` file if miss unityLoader attribute, exported by Unity in your base html file, index.html in example.
31 |
32 |
33 |
34 | ## Optional attributes
35 |
36 | * `src` - Path to json build
37 | * `width` - width div container
38 | * `height` - height div container
39 | * `unityLoader` - path to UnityLoader, with this
40 |
41 |
42 | # Communication
43 | Unity allows you to send Javascript messages to the Unity content. In order to do so using VueJs you have to add a ref to the `` tag, and call the `message(object, method, param)` method through `this.$refs`.
44 |
45 | ```js
46 |
47 |
48 |
49 |
50 |
61 | ```
62 |
63 | # styling
64 | The player will be injected in the a component with the class `unity-container`. To style to player use the following sass styling. To style the loader you can style the component with the class `unity-loader`. See the example below.
65 |
66 | ```scss
67 | .unity {
68 | .unity-container {
69 | canvas {
70 |
71 | }
72 | }
73 | .unity-loader {
74 | .bar {
75 | .fill {
76 | /* the width will be set by the component */
77 | }
78 | }
79 | }
80 | }
81 | ```
82 |
83 | # html example
84 | ```html
85 |
86 |
87 |
88 | My Unity Game
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | ```
--------------------------------------------------------------------------------
/src/Unity.vue:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
115 |
--------------------------------------------------------------------------------