Skip to content

Commit d438d65

Browse files
committed
init :fire :dra: 🐉 🔥
0 parents  commit d438d65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+470
-0
lines changed

.browserslistrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
> 1%
2+
last 2 versions
3+
not ie <= 8

.eslintrc.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
'extends': [
7+
'plugin:vue/essential',
8+
'eslint:recommended'
9+
],
10+
rules: {
11+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
13+
},
14+
parserOptions: {
15+
parser: 'babel-eslint'
16+
}
17+
}

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?

Home.vue

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<unity src="static/Build/game.json" width="1000" height="600" unityLoader="static/Build/UnityLoader.js" ref="uInstance"></unity>
3+
</template>
4+
<script>
5+
import Web3 from "web3"
6+
import Unity from 'vue-unity-webgl'
7+
8+
export default {
9+
name: 'home',
10+
data() {
11+
return {
12+
web3: null
13+
}
14+
},
15+
created() {
16+
this.web3 = new Web3(web3.currentProvider)
17+
},
18+
methods: {
19+
onClick () {
20+
this.$refs.myInstance.message("object", "method", "param")
21+
}
22+
}
23+
}
24+
</script>
25+
26+
27+
28+
<script>
29+
import Unity from 'vue-unity-webgl'
30+
31+
new Vue({
32+
methods: {
33+
onClick () {
34+
this.$refs.uInstance.message("object", "method", "param")
35+
}
36+
}
37+
})
38+
</script>

README.md

+36

babel.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}

index.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<title>Unity WebGL Player | EthConnect</title>
7+
<link rel="shortcut icon" href="TemplateData/favicon.ico">
8+
<link rel="stylesheet" href="TemplateData/style.css">
9+
<script src="TemplateData/UnityProgress.js"></script>
10+
<script src="Build/UnityLoader.js"></script>
11+
<script>
12+
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGL-Test.json", {onProgress: UnityProgress});
13+
</script>
14+
<script src="web3.js"></script>
15+
<script type="text/javascript">
16+
const web3 = new Web3(Web3.currentProvider);
17+
async function requestAccounts(){
18+
let request = await web3.eth.requestAccounts();
19+
}
20+
21+
async function getNetwork(){
22+
let network = await web3.eth.net.getNetworkType();
23+
return network;
24+
}
25+
26+
async function getAccount(){
27+
let accounts = await web3.eth.getAccounts()
28+
return accounts[0];
29+
}
30+
31+
requestAccounts();
32+
console.log(getNetwork());
33+
console.log(getAccount());
34+
35+
console.log(network)
36+
console.log(account)
37+
38+
</script>
39+
</head>
40+
<body>
41+
<div class="webgl-content">
42+
<div id="gameContainer" style="width: 960px; height: 600px"></div>
43+
<div class="footer">
44+
<div class="webgl-logo"></div>
45+
<div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
46+
<div class="title">EthConnect</div>
47+
</div>
48+
</div>
49+
</body>
50+
</html>

package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "unity-vue-boilerplate",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"core-js": "^2.6.5",
12+
"vue": "^2.6.10",
13+
"vue-router": "^3.0.3",
14+
"vue-unity-webgl": "^1.2.0",
15+
"vuex": "^3.0.1"
16+
},
17+
"devDependencies": {
18+
"@vue/cli-plugin-babel": "^3.6.0",
19+
"@vue/cli-plugin-eslint": "^3.6.0",
20+
"@vue/cli-service": "^3.6.0",
21+
"babel-eslint": "^10.0.1",
22+
"eslint": "^5.16.0",
23+
"eslint-plugin-vue": "^5.0.0",
24+
"vue-template-compiler": "^2.5.21"
25+
}
26+
}

postcss.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
plugins: {
3+
autoprefixer: {}
4+
}
5+
}

public/Build/UnityLoader.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/Build/WebGL-Test.data.unityweb

1.13 MB
Binary file not shown.

public/Build/WebGL-Test.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"companyName": "DefaultCompany",
3+
"productName": "EthConnect",
4+
"dataUrl": "WebGL-Test.data.unityweb",
5+
"wasmCodeUrl": "WebGL-Test.wasm.code.unityweb",
6+
"wasmFrameworkUrl": "WebGL-Test.wasm.framework.unityweb",
7+
"TOTAL_MEMORY": 268435456,
8+
"graphicsAPI": ["WebGL 2.0", "WebGL 1.0"],
9+
"webglContextAttributes": {"preserveDrawingBuffer": false},
10+
"splashScreenStyle": "Dark",
11+
"backgroundColor": "#231F20",
12+
"cacheControl": {"default": "must-revalidate"}
13+
}
3.83 MB
Binary file not shown.
90.3 KB
Binary file not shown.

public/TemplateData/UnityProgress.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function UnityProgress(gameInstance, progress) {
2+
if (!gameInstance.Module)
3+
return;
4+
if (!gameInstance.logo) {
5+
gameInstance.logo = document.createElement("div");
6+
gameInstance.logo.className = "logo " + gameInstance.Module.splashScreenStyle;
7+
gameInstance.container.appendChild(gameInstance.logo);
8+
}
9+
if (!gameInstance.progress) {
10+
gameInstance.progress = document.createElement("div");
11+
gameInstance.progress.className = "progress " + gameInstance.Module.splashScreenStyle;
12+
gameInstance.progress.empty = document.createElement("div");
13+
gameInstance.progress.empty.className = "empty";
14+
gameInstance.progress.appendChild(gameInstance.progress.empty);
15+
gameInstance.progress.full = document.createElement("div");
16+
gameInstance.progress.full.className = "full";
17+
gameInstance.progress.appendChild(gameInstance.progress.full);
18+
gameInstance.container.appendChild(gameInstance.progress);
19+
}
20+
gameInstance.progress.full.style.width = (100 * progress) + "%";
21+
gameInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
22+
if (progress == 1)
23+
gameInstance.logo.style.display = gameInstance.progress.style.display = "none";
24+
}

public/TemplateData/favicon.ico

13 KB
Binary file not shown.

public/TemplateData/fullscreen.png

345 Bytes
155 Bytes
159 Bytes
137 Bytes
142 Bytes
2.29 KB
2.21 KB

public/TemplateData/style.css

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.webgl-content * {border: 0; margin: 0; padding: 0}
2+
.webgl-content {position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
3+
4+
.webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
5+
.webgl-content .logo {background: url('progressLogo.Light.png') no-repeat center / contain; width: 154px; height: 130px;}
6+
.webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
7+
.webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
8+
.webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}
9+
10+
.webgl-content .logo.Dark {background-image: url('progressLogo.Dark.png');}
11+
.webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
12+
.webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}
13+
14+
.webgl-content .footer {margin-top: 5px; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
15+
.webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
16+
.webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
17+
.webgl-content .footer .title {margin-right: 10px; float: right;}
18+
.webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}

public/TemplateData/webgl-logo.png

3.5 KB

public/favicon.ico

4.19 KB
Binary file not shown.

public/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<link rel="stylesheet" href="TemplateData/style.css">
9+
<title>Unity Vue Boilerplate</title>
10+
</head>
11+
<body>
12+
<noscript>
13+
<strong>Please enable JavaScript or use a JS-compatible browser to continue.</strong>
14+
</noscript>
15+
<div id="app"></div>
16+
<!-- built files will be auto injected -->
17+
</body>
18+
</html>

scripts/external-communication.cs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
// ABOUT RUNNING JS FUNCS
6+
// https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
7+
8+
// nethereum
9+
// https://medium.com/@juanfranblanco/nethereum-2-0-0-rc5-unity3d-integration-eb7664664813
10+
11+
public class GetEth : MonoBehaviour
12+
{
13+
[DllImport("__Internal")]
14+
private static extern string SendTransaction(string to, string data);
15+
16+
// Start is called before the first frame update
17+
void Start()
18+
{
19+
Debug.Log("I'm attached to " + gameObject.name);
20+
gameObject.GetComponent<TextMesh>().text = "PWND";
21+
22+
}
23+
24+
// Update is called once per frame
25+
void Update()
26+
{
27+
}
28+
29+
public void SetText(string arg)
30+
{
31+
gameObject.GetComponent<TextMesh>().text = arg;
32+
33+
}
34+
}

src/App.vue

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div id="app">
3+
<div id="nav">
4+
<router-link to="/">Home</router-link> |
5+
<router-link to="/about">About</router-link>
6+
</div>
7+
<router-view/>
8+
</div>
9+
</template>
10+
11+
<style>
12+
13+
</style>

src/assets/Build/UnityLoader.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.13 MB
Binary file not shown.

src/assets/Build/WebGL-Test.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"companyName": "DefaultCompany",
3+
"productName": "EthConnect",
4+
"dataUrl": "WebGL-Test.data.unityweb",
5+
"wasmCodeUrl": "WebGL-Test.wasm.code.unityweb",
6+
"wasmFrameworkUrl": "WebGL-Test.wasm.framework.unityweb",
7+
"TOTAL_MEMORY": 268435456,
8+
"graphicsAPI": ["WebGL 2.0", "WebGL 1.0"],
9+
"webglContextAttributes": {"preserveDrawingBuffer": false},
10+
"splashScreenStyle": "Dark",
11+
"backgroundColor": "#231F20",
12+
"cacheControl": {"default": "must-revalidate"}
13+
}
3.66 MB
Binary file not shown.
Binary file not shown.
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function UnityProgress(gameInstance, progress) {
2+
if (!gameInstance.Module)
3+
return;
4+
if (!gameInstance.logo) {
5+
gameInstance.logo = document.createElement("div");
6+
gameInstance.logo.className = "logo " + gameInstance.Module.splashScreenStyle;
7+
gameInstance.container.appendChild(gameInstance.logo);
8+
}
9+
if (!gameInstance.progress) {
10+
gameInstance.progress = document.createElement("div");
11+
gameInstance.progress.className = "progress " + gameInstance.Module.splashScreenStyle;
12+
gameInstance.progress.empty = document.createElement("div");
13+
gameInstance.progress.empty.className = "empty";
14+
gameInstance.progress.appendChild(gameInstance.progress.empty);
15+
gameInstance.progress.full = document.createElement("div");
16+
gameInstance.progress.full.className = "full";
17+
gameInstance.progress.appendChild(gameInstance.progress.full);
18+
gameInstance.container.appendChild(gameInstance.progress);
19+
}
20+
gameInstance.progress.full.style.width = (100 * progress) + "%";
21+
gameInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
22+
if (progress == 1)
23+
gameInstance.logo.style.display = gameInstance.progress.style.display = "none";
24+
}

src/assets/TemplateData/favicon.ico

13 KB
Binary file not shown.
345 Bytes
155 Bytes
159 Bytes
137 Bytes
142 Bytes
2.29 KB
2.21 KB

src/assets/TemplateData/style.css

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.webgl-content * {border: 0; margin: 0; padding: 0}
2+
.webgl-content {position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
3+
4+
.webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
5+
.webgl-content .logo {background: url('progressLogo.Light.png') no-repeat center / contain; width: 154px; height: 130px;}
6+
.webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
7+
.webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
8+
.webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}
9+
10+
.webgl-content .logo.Dark {background-image: url('progressLogo.Dark.png');}
11+
.webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
12+
.webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}
13+
14+
.webgl-content .footer {margin-top: 5px; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
15+
.webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
16+
.webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
17+
.webgl-content .footer .title {margin-right: 10px; float: right;}
18+
.webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}
3.5 KB

src/assets/logo.png

6.69 KB

0 commit comments

Comments
 (0)