Skip to content

Instantly share code, notes, and snippets.

@adash333
Last active August 18, 2019 14:45
Show Gist options
  • Save adash333/576c1064f904fb3ee8d3771cd51b09de to your computer and use it in GitHub Desktop.
Save adash333/576c1064f904fb3ee8d3771cd51b09de to your computer and use it in GitHub Desktop.
<template>
<div id="app">
<header>
<span>Vue.js PWA</span>
</header>
<main>
<unity
src="public/unityBuild/Build/unityBuild.json"
v-bind="{ width: gameWidth, height: gameHeight }"
unityLoader="public/unityBuild/Build/UnityLoader.js"
></unity>
</main>
</div>
</template>
<script>
import unity from "vue-unity-webgl";
export default {
name: "app",
data: function() {
return {
gameWidth: window.innerWidth,
gameHeight: window.innerHeight * 0.96 - 134 // 134はヘッダー等の値
};
},
methods: {
handleResize: function() {
this.gameWidth = window.innerWidth;
this.gameHeight = window.innerHeight;
}
},
ready: function() {
window.addEventListener("resize", this.handleResize);
},
beforeDestroy: function() {
window.removeEventListener("resize", this.handleResize);
},
components: { unity }
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment