移动端测试
This commit is contained in:
8
Assets/WebGLTemplates/DefaultTemplate/TemplateData.meta
Normal file
8
Assets/WebGLTemplates/DefaultTemplate/TemplateData.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf34cef120f6d5459a46b06eff62a07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 401 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3d548910ab190741870d32336dcae9f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/WebGLTemplates/DefaultTemplate/TemplateData/favicon.ico
Normal file
BIN
Assets/WebGLTemplates/DefaultTemplate/TemplateData/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60daaee6df4b6904b9b5c99351f040de
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 540e66911c73cc84e912b1bf0d660257
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df26eead11df0654c8c2011c1dd8443e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
79
Assets/WebGLTemplates/DefaultTemplate/TemplateData/style.css
Normal file
79
Assets/WebGLTemplates/DefaultTemplate/TemplateData/style.css
Normal file
@ -0,0 +1,79 @@
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background: url('background.png');
|
||||
background-size: cover;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#unity-container {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#unity-container.unity-desktop {
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%)
|
||||
}
|
||||
|
||||
#unity-container.unity-mobile {
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
|
||||
#unity-canvas {
|
||||
background: url('background.png') no-repeat center
|
||||
}
|
||||
|
||||
.unity-mobile #unity-canvas {
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
|
||||
#unity-loading-bar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#unity-loading-img {
|
||||
margin-left: 20%;
|
||||
}
|
||||
|
||||
#unity-loadtext {
|
||||
width: 200px;
|
||||
height: 30px;
|
||||
margin: 0 auto;
|
||||
color: aliceblue;
|
||||
}
|
||||
|
||||
#unity-progress-bar-empty {
|
||||
width: 50%;
|
||||
height: 15px;
|
||||
border-radius: 10px;
|
||||
margin: 0 auto;
|
||||
background: url('progress-bar-empty-dark.png') no-repeat center
|
||||
}
|
||||
|
||||
#unity-progress-bar-full {
|
||||
height: 100%;
|
||||
border-radius: 10px;
|
||||
width: 0%;
|
||||
background: url('progress-bar-full-dark.png') no-repeat center
|
||||
}
|
||||
|
||||
#unity-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 5%;
|
||||
transform: translate(-50%);
|
||||
background: white;
|
||||
padding: 10px;
|
||||
display: none
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0bf40f881180eb4dbd8eca6d51e9cbd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
137
Assets/WebGLTemplates/DefaultTemplate/index.html
Normal file
137
Assets/WebGLTemplates/DefaultTemplate/index.html
Normal file
@ -0,0 +1,137 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>调蓄池数据</title>
|
||||
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
||||
<link rel="stylesheet" href="TemplateData/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="unity-container" class="unity-desktop">
|
||||
<div id="unity-loading-bar">
|
||||
<div id="unity-progress-bar-empty">
|
||||
<div id="unity-progress-bar-full"></div>
|
||||
</div>
|
||||
<div id="unity-loadtext">数据加载中...(0%)</div>
|
||||
</div>
|
||||
<canvas id="unity-canvas" width=960 height=600></canvas>
|
||||
<div id="unity-warning"> </div>
|
||||
<div id="unity-footer">
|
||||
<div id="unity-webgl-logo"></div>
|
||||
<div id="unity-fullscreen-button"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var container = document.querySelector("#unity-container");
|
||||
var canvas = document.querySelector("#unity-canvas");
|
||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
||||
//var loadingLogo = document.querySelector("#unity-loading-img");
|
||||
var loadingText = document.querySelector("#unity-loadtext");
|
||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
||||
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
||||
var warningBanner = document.querySelector("#unity-warning");
|
||||
|
||||
|
||||
/*
|
||||
通过调用此方法发送消息给Unity内部,参数依次为:模型ID、模型名称、模型介绍、谁用(0:正常 1:理化生)
|
||||
举例:HtmlToUnity("1","霸王龙","简介","0");
|
||||
*/
|
||||
function HtmlToUnity(id, name, describe, type) {
|
||||
var parameters = (id === undefined ? "" : id) + "|" +
|
||||
(name === undefined ? "" : name) + "|" +
|
||||
(describe === undefined ? "" : describe) + "|" +
|
||||
(type === undefined ? "" : type);
|
||||
unityInstnac.SendMessage("Common", "SetModelInfo", parameters);
|
||||
}
|
||||
|
||||
function JumpToURL(str) {
|
||||
window.open(str, '_self');
|
||||
}
|
||||
|
||||
function SendFinish(str) {
|
||||
progressBarFull.style.width = 100 * str + "%";
|
||||
loadingText.textContent = "数据加载中...(" + parseInt(100 * str) + "%)";
|
||||
//loadingLogo.style.marginLeft = 20 + (str * 50) + "%";
|
||||
if (str == 1) {
|
||||
loadingBar.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
var unityInstnac;
|
||||
|
||||
var buildUrl = "Build";
|
||||
var loaderUrl = buildUrl + "/TXC.loader.js";
|
||||
var config = {
|
||||
dataUrl: buildUrl + "/TXC.data",
|
||||
frameworkUrl: buildUrl + "/TXC.framework.js",
|
||||
codeUrl: buildUrl + "/TXC.wasm",
|
||||
streamingAssetsUrl: "StreamingAssets",
|
||||
companyName: "DefaultCompany",
|
||||
productName: "DXC",
|
||||
productVersion: "0.1.0",
|
||||
};
|
||||
|
||||
|
||||
// By default Unity keeps WebGL canvas render target size matched with
|
||||
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
||||
// Set this to false if you want to decouple this synchronization from
|
||||
// happening inside the engine, and you would instead like to size up
|
||||
// the canvas DOM size and WebGL render target sizes yourself.
|
||||
// config.matchWebGLToCanvasSize = false;
|
||||
|
||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
||||
// Mobile device style: fill the whole browser client area with the game canvas:
|
||||
|
||||
var meta = document.createElement('meta');
|
||||
meta.name = 'viewport';
|
||||
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
|
||||
document.getElementsByTagName('head')[0].appendChild(meta);
|
||||
container.className = "unity-mobile";
|
||||
canvas.className = "unity-mobile";
|
||||
|
||||
// To lower canvas resolution on mobile devices to gain some
|
||||
// performance, uncomment the following line:
|
||||
config.devicePixelRatio = 1;
|
||||
|
||||
// unityShowBanner('WebGL builds are not supported on mobile devices.');
|
||||
} else {
|
||||
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
|
||||
|
||||
canvas.style.width = "100%";
|
||||
canvas.style.height = "100%";
|
||||
}
|
||||
|
||||
|
||||
loadingBar.style.display = "flex";
|
||||
//loadingLogo.src = ""
|
||||
var script = document.createElement("script");
|
||||
script.src = loaderUrl;
|
||||
script.onload = () => {
|
||||
createUnityInstance(canvas, config, (progress) => {
|
||||
progressBarFull.style.width = 100 * (progress) + "%";
|
||||
loadingText.textContent = "数据加载中...(" + parseInt(100 * (progress)) + "%)";
|
||||
//loadingLogo.style.marginLeft = 20 + ((progress) * 50) + "%";
|
||||
}).then((unityInstance) => {
|
||||
unityInstnac = unityInstance;
|
||||
setTimeout(function () {
|
||||
var url = window.location.href;
|
||||
var result = url.split("?");
|
||||
var parameters = "";
|
||||
if (result.length > 1) {
|
||||
parameters = result[1];
|
||||
}
|
||||
loadingBar.style.display = "none";
|
||||
//unityInstance.SendMessage("Common", "SetRoomData", parameters);
|
||||
}, 500);
|
||||
}).catch((message) => {
|
||||
alert(message);
|
||||
});
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
7
Assets/WebGLTemplates/DefaultTemplate/index.html.meta
Normal file
7
Assets/WebGLTemplates/DefaultTemplate/index.html.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ba1c32c441193040b67764aa3074229
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user