-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
183 lines (167 loc) · 4.53 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Web_Template_2023</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
height: 100%;
width: 100%;
text-align: center;
background-color: #000;
}
#unity-canvas {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
#unity-loading-bar {
position: absolute;
left: 30%;
top: 50%;
width: 40%;
height: 20px;
background-color: #fff;
border: 5px solid #ccc;
border-radius: 20px;
}
#unity-progress-bar {
position: absolute;
left: 0%;
top: 0%;
width: 1%;
height: 100%;
background-color: #ef6817;
border-radius: 20px;
transition: 400ms linear;
}
#games4king{
position: absolute;
left: 0%;
top: 15%;
width: 100%;
height: 25%;
object-fit: contain;
}
#android{
position: absolute;
left: 0%;
bottom: 15%;
width: 100%;
height: 25%;
object-fit: contain;
}
</style>
</head>
<body>
<img src="games4king.png" id="games4king">
<img src="android.png" id="android">
<canvas id="unity-canvas"></canvas>
<div id="unity-loading-bar">
<div id="unity-progress-bar">
</div>
</div>
<script src="Build/Web2.loader.js"></script>
<script>
const maxPixelRatioMobile = 2.0;
const maxPixelRatioDesktop = 1.5;
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
var maxDevicePixelRatio = isMobile? maxPixelRatioMobile: maxPixelRatioDesktop;
var pixelRatio = Math.min(window.devicePixelRatio, maxDevicePixelRatio);
var buildUrl = "Build";
var loaderUrl = buildUrl + "/Web2.loader.js";
var config = {
dataUrl: buildUrl + "/Web2.data.unityweb",
frameworkUrl: buildUrl + "/Web2.framework.js.unityweb",
codeUrl: buildUrl + "/Web2.wasm.unityweb",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "Web_Template_2023",
productVersion: "1.0",
devicePixelRatio: pixelRatio
};
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBar = document.querySelector("#unity-progress-bar");
var game_mc;
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = function() {
createUnityInstance(canvas, config, function(progress) {
progressBar.style.width = 100 * progress + "%";
}).then(function(unityInstance)
{
game_mc=unityInstance;
loadingBar.style.display = "none";
}).catch(function(message) {
alert(message);
});
};
document.body.appendChild(script);
// Listen for messages from the iframe
window.addEventListener('message', function(event) {
// If the message is a request for the grandparent domain name
if (event.data && event.data.type === 'getGrandparentDomain') {
// Get the domain name of the grandparent window
var grandparentDomain = window.parent.location.hostname;
// Send a message to the iframe containing the grandparent domain name
event.source.postMessage({ type: 'grandparentDomain', domain: grandparentDomain }, event.origin);
}
});
function gd_ad_call()
{
}
function pause_status(pause_val)
{
game_mc.SendMessage("Canvas", "game_pause_status", pause_val);
}
function game_music_control(music)
{
game_mc.SendMessage("Canvas", "game_music_control", music);
}
function game_vfx_control(vfx)
{
game_mc.SendMessage("Canvas", "game_vfx_control",vfx);
}
function coin_update_fun(coin)
{
game_mc.SendMessage("Canvas", "android_coin_update", coin);
}
function move_update_fun1(val1)
{
game_mc.SendMessage("Canvas", "move_val_fun1", val1);
}
function move_update_fun2(val2)
{
game_mc.SendMessage("Canvas", "move_val_fun2", val2);
}
function move_update_fun3(val3)
{
game_mc.SendMessage("Canvas", "move_val_fun3", val3);
}
function back_to_game()
{
game_mc.SendMessage("Canvas", "back_to_game");
}
function gravity_strfun(gravity_str)
{
game_mc.SendMessage("Canvas", "gravity_get_strfun", gravity_str);
}
function gravity_status(gravity_val)
{
game_mc.SendMessage("Canvas", "gravity_get_fun", gravity_val);
}
function gravity_fn()
{
game_mc.SendMessage("Canvas", "gra_fun");
}
</script>
</body>
</html>