cm107 commited on
Commit
d8734b7
1 Parent(s): 8c33d0f

Changed the size of the game window.

Browse files

Loading bar position and size needs to be fixed too.

Files changed (3) hide show
  1. gameLoad.js +64 -0
  2. index.html +1 -66
  3. main.css +8 -0
gameLoad.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const hideFullScreenButton = "";
2
+ const buildUrl = "Build";
3
+ const loaderUrl = buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.loader.js";
4
+ const config = {
5
+ dataUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.data",
6
+ frameworkUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.framework.js",
7
+ codeUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.wasm",
8
+ streamingAssetsUrl: "StreamingAssets",
9
+ companyName: "DefaultCompany",
10
+ productName: "excav_simul_3d",
11
+ productVersion: "0.1",
12
+ };
13
+
14
+ const container = document.querySelector("#unity-container");
15
+ const canvas = document.querySelector("#unity-canvas");
16
+ const loadingCover = document.querySelector("#loading-cover");
17
+ const progressBarEmpty = document.querySelector("#unity-progress-bar-empty");
18
+ const progressBarFull = document.querySelector("#unity-progress-bar-full");
19
+ const fullscreenButton = document.querySelector("#unity-fullscreen-button");
20
+ const spinner = document.querySelector('.spinner');
21
+
22
+ const canFullscreen = (function () {
23
+ for (const key of [
24
+ 'exitFullscreen',
25
+ 'webkitExitFullscreen',
26
+ 'webkitCancelFullScreen',
27
+ 'mozCancelFullScreen',
28
+ 'msExitFullscreen',
29
+ ]) {
30
+ if (key in document) {
31
+ return true;
32
+ }
33
+ }
34
+ return false;
35
+ }());
36
+
37
+ if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
38
+ container.className = "unity-mobile";
39
+ config.devicePixelRatio = 1;
40
+ }
41
+ loadingCover.style.display = "";
42
+
43
+ const script = document.createElement("script");
44
+ script.src = loaderUrl;
45
+ script.onload = () => {
46
+ createUnityInstance(canvas, config, (progress) => {
47
+ spinner.style.display = "none";
48
+ progressBarEmpty.style.display = "";
49
+ progressBarFull.style.width = `${100 * progress}%`;
50
+ }).then((unityInstance) => {
51
+ loadingCover.style.display = "none";
52
+ if (canFullscreen) {
53
+ if (!hideFullScreenButton) {
54
+ fullscreenButton.style.display = "";
55
+ }
56
+ fullscreenButton.onclick = () => {
57
+ unityInstance.SetFullscreen(1);
58
+ };
59
+ }
60
+ }).catch((message) => {
61
+ alert(message);
62
+ });
63
+ };
64
+ document.body.appendChild(script);
index.html CHANGED
@@ -25,72 +25,7 @@
25
  </div>
26
  </div>
27
  <div id="unity-fullscreen-button" style="display: none;"></div>
28
- <script>
29
- const hideFullScreenButton = "";
30
- const buildUrl = "Build";
31
- const loaderUrl = buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.loader.js";
32
- const config = {
33
- dataUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.data",
34
- frameworkUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.framework.js",
35
- codeUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-light-demo-webgl-dev.wasm",
36
- streamingAssetsUrl: "StreamingAssets",
37
- companyName: "DefaultCompany",
38
- productName: "excav_simul_3d",
39
- productVersion: "0.1",
40
- };
41
-
42
- const container = document.querySelector("#unity-container");
43
- const canvas = document.querySelector("#unity-canvas");
44
- const loadingCover = document.querySelector("#loading-cover");
45
- const progressBarEmpty = document.querySelector("#unity-progress-bar-empty");
46
- const progressBarFull = document.querySelector("#unity-progress-bar-full");
47
- const fullscreenButton = document.querySelector("#unity-fullscreen-button");
48
- const spinner = document.querySelector('.spinner');
49
-
50
- const canFullscreen = (function () {
51
- for (const key of [
52
- 'exitFullscreen',
53
- 'webkitExitFullscreen',
54
- 'webkitCancelFullScreen',
55
- 'mozCancelFullScreen',
56
- 'msExitFullscreen',
57
- ]) {
58
- if (key in document) {
59
- return true;
60
- }
61
- }
62
- return false;
63
- }());
64
-
65
- if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
66
- container.className = "unity-mobile";
67
- config.devicePixelRatio = 1;
68
- }
69
- loadingCover.style.display = "";
70
-
71
- const script = document.createElement("script");
72
- script.src = loaderUrl;
73
- script.onload = () => {
74
- createUnityInstance(canvas, config, (progress) => {
75
- spinner.style.display = "none";
76
- progressBarEmpty.style.display = "";
77
- progressBarFull.style.width = `${100 * progress}%`;
78
- }).then((unityInstance) => {
79
- loadingCover.style.display = "none";
80
- if (canFullscreen) {
81
- if (!hideFullScreenButton) {
82
- fullscreenButton.style.display = "";
83
- }
84
- fullscreenButton.onclick = () => {
85
- unityInstance.SetFullscreen(1);
86
- };
87
- }
88
- }).catch((message) => {
89
- alert(message);
90
- });
91
- };
92
- document.body.appendChild(script);
93
- </script>
94
  <div id="infoBox">
95
  <h1>Controls</h1>
96
  <div id="controls">
 
25
  </div>
26
  </div>
27
  <div id="unity-fullscreen-button" style="display: none;"></div>
28
+ <script type="text/javascript" src="gameLoad.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  <div id="infoBox">
30
  <h1>Controls</h1>
31
  <div id="controls">
main.css CHANGED
@@ -42,4 +42,12 @@ td {
42
  #disclaimerBody {
43
  color: red;
44
  margin-left: 30px;
 
 
 
 
 
 
 
 
45
  }
 
42
  #disclaimerBody {
43
  color: red;
44
  margin-left: 30px;
45
+ }
46
+
47
+ #unity-container {
48
+ /* TODO */
49
+ width: 66%;
50
+ height: 66%;
51
+ margin-left: auto;
52
+ margin-right: auto;
53
  }