Browse Source

Messing around with HTML

master
JoshuaReason 5 years ago
parent
commit
100e4f1ece
15 changed files with 312 additions and 24 deletions
  1. +2
    -2
      Assets/Data/Inventory/BaseInventory.asset
  2. +2
    -2
      Assets/Data/Logic Blocks/Missile.asset
  3. +4
    -0
      Assets/Scripts/Browser/BrowserServer.cs
  4. +1
    -1
      Assets/Scripts/Browser/SimpleHttpsServer.cs
  5. +3
    -0
      Assets/StreamingAssets/WebGLBuild/TemplateData/logo.png
  6. +7
    -0
      Assets/StreamingAssets/WebGLBuild/TemplateData/logo.png.meta
  7. +123
    -16
      Assets/StreamingAssets/WebGLBuild/index.html
  8. +8
    -0
      Assets/WebGLTemplates.meta
  9. +9
    -0
      Assets/WebGLTemplates/BetterTemplate.meta
  10. +132
    -0
      Assets/WebGLTemplates/BetterTemplate/index.html
  11. +8
    -0
      Assets/WebGLTemplates/BetterTemplate/index.html.meta
  12. +3
    -0
      Assets/WebGLTemplates/BetterTemplate/logo.png
  13. +7
    -0
      Assets/WebGLTemplates/BetterTemplate/logo.png.meta
  14. +1
    -1
      ProjectSettings/EditorBuildSettings.asset
  15. +2
    -2
      ProjectSettings/ProjectSettings.asset

+ 2
- 2
Assets/Data/Inventory/BaseInventory.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:3fb94665e70a106a7e0a4ca21efd8c70634b208c2c9bcc75a6601c8a846c559b
size 1186
oid sha256:c81ff8a2a9d20a7dbf315a47e3f940b787afa602a751c355d85b064e6b90a9fd
size 1313

+ 2
- 2
Assets/Data/Logic Blocks/Missile.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1407c67c7a52ce8f47e9373bd2c3663187ab8993f107ef768d5db368c59bc873
size 573
oid sha256:f41bc326800dd1e6b56d27fe30a4bc8e8fe02db38d6753dc156ce3416db2c0ab
size 651

+ 4
- 0
Assets/Scripts/Browser/BrowserServer.cs View File

@ -13,6 +13,10 @@ public class BrowserServer : MonoBehaviour
[Tooltip("Local Path in Streaming Assets")] [Tooltip("Local Path in Streaming Assets")]
private string LocalPath; private string LocalPath;
[SerializeField]
[Tooltip("Site to redirect to if android")]
private string redirectSite;
[SerializeField] [SerializeField]
[Tooltip("Browsers by default use 80")] [Tooltip("Browsers by default use 80")]
private int port = 80; private int port = 80;

+ 1
- 1
Assets/Scripts/Browser/SimpleHttpsServer.cs View File

@ -142,8 +142,8 @@ class SimpleHTTPServer
try try
{ {
HttpListenerContext context = _listener.GetContext(); HttpListenerContext context = _listener.GetContext();
UnityEngine.Debug.Log("client Connected to webpage");
Process(context); Process(context);
} }
catch (Exception ex) catch (Exception ex)
{ {

+ 3
- 0
Assets/StreamingAssets/WebGLBuild/TemplateData/logo.png View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c963d84120be6c9dbd55078d72c6872b193294304954c55db22267f0d5317452
size 7257

+ 7
- 0
Assets/StreamingAssets/WebGLBuild/TemplateData/logo.png.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73ef2099cc3789e4082152b3e189b9a7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 123
- 16
Assets/StreamingAssets/WebGLBuild/index.html View File

@ -1,25 +1,132 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en-us"> <html lang="en-us">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Pet.Move()</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGLBuild.json", {onProgress: UnityProgress});
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>%UNITY_WEB_NAME%</title>
<style>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #444;
}
#gameContainer {
width: 100vw;
height: 100vh;
}
canvas {
width: 100%;
height: 100%;
display: block;
}
/* try to handle mobile dialog */
canvas + * {
z-index: 2;
}
.logo {
display: block;
max-width: 100vw;
max-height: 70vh;
}
.progress {
margin: 1.5em;
border: 1px solid white;
width: 50vw;
display: none;
}
.progress .full {
margin: 2px;
background: white;
height: 1em;
transform-origin: top left;
}
#loader {
position: absolute;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.spinner,
.spinner:after {
border-radius: 50%;
width: 5em;
height: 5em;
}
.spinner {
margin: 10px;
font-size: 10px;
position: relative;
text-indent: -9999em;
border-top: 1.1em solid rgba(255, 255, 255, 0.2);
border-right: 1.1em solid rgba(255, 255, 255, 0.2);
border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
border-left: 1.1em solid #ffffff;
transform: translateZ(0);
animation: spinner-spin 1.1s infinite linear;
}
@keyframes spinner-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head> </head>
<body> <body>
<div class="webgl-content">
<div id="gameContainer" style="width: 960px; height: 600px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
<div class="title">Pet.Move()</div>
</div>
<div id="gameContainer"></div>
<div id="loader">
<img class="logo" src="logo.png">
<div class="spinner"></div>
<div class="progress"><div class="full"></div></div>
</div> </div>
</body> </body>
<script src="%UNITY_WEBGL_LOADER_URL%"></script>
<script>
if (UnityLoader.SystemInfo.mobile)
{
window.location.replace("http://www.google.com");
}
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
function UnityProgress(gameInstance, progress) {
if (!gameInstance.Module) {
return;
}
const loader = document.querySelector("#loader");
if (!gameInstance.progress) {
const progress = document.querySelector("#loader .progress");
progress.style.display = "block";
gameInstance.progress = progress.querySelector(".full");
loader.querySelector(".spinner").style.display = "none";
}
gameInstance.progress.style.transform = `scaleX(${progress})`;
if (progress === 1 && !gameInstance.removeTimeout) {
gameInstance.removeTimeout = setTimeout(function() {
loader.style.display = "none";
}, 2000);
}
}
</script>
</html> </html>

+ 8
- 0
Assets/WebGLTemplates.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ce76274a22d5f1749afb0d99b29039dc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
Assets/WebGLTemplates/BetterTemplate.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f25bb8e07ed2f4b20aa116e1c94cea0a
folderAsset: yes
timeCreated: 1510669965
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 132
- 0
Assets/WebGLTemplates/BetterTemplate/index.html View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>%UNITY_WEB_NAME%</title>
<style>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #444;
}
#gameContainer {
width: 100vw;
height: 100vh;
}
canvas {
width: 100%;
height: 100%;
display: block;
}
/* try to handle mobile dialog */
canvas + * {
z-index: 2;
}
.logo {
display: block;
max-width: 100vw;
max-height: 70vh;
}
.progress {
margin: 1.5em;
border: 1px solid white;
width: 50vw;
display: none;
}
.progress .full {
margin: 2px;
background: white;
height: 1em;
transform-origin: top left;
}
#loader {
position: absolute;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.spinner,
.spinner:after {
border-radius: 50%;
width: 5em;
height: 5em;
}
.spinner {
margin: 10px;
font-size: 10px;
position: relative;
text-indent: -9999em;
border-top: 1.1em solid rgba(255, 255, 255, 0.2);
border-right: 1.1em solid rgba(255, 255, 255, 0.2);
border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
border-left: 1.1em solid #ffffff;
transform: translateZ(0);
animation: spinner-spin 1.1s infinite linear;
}
@keyframes spinner-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div id="gameContainer"></div>
<div id="loader">
<img class="logo" src="logo.png">
<div class="spinner"></div>
<div class="progress"><div class="full"></div></div>
</div>
</body>
<script src="%UNITY_WEBGL_LOADER_URL%"></script>
<script>
if (UnityLoader.SystemInfo.mobile)
{
window.location.replace("http://www.google.com");
}
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
function UnityProgress(gameInstance, progress) {
if (!gameInstance.Module) {
return;
}
const loader = document.querySelector("#loader");
if (!gameInstance.progress) {
const progress = document.querySelector("#loader .progress");
progress.style.display = "block";
gameInstance.progress = progress.querySelector(".full");
loader.querySelector(".spinner").style.display = "none";
}
gameInstance.progress.style.transform = `scaleX(${progress})`;
if (progress === 1 && !gameInstance.removeTimeout) {
gameInstance.removeTimeout = setTimeout(function() {
loader.style.display = "none";
}, 2000);
}
}
</script>
</html>

+ 8
- 0
Assets/WebGLTemplates/BetterTemplate/index.html.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 21a732ac9afba41ce9d0f72567db331f
timeCreated: 1510670098
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/WebGLTemplates/BetterTemplate/logo.png View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c963d84120be6c9dbd55078d72c6872b193294304954c55db22267f0d5317452
size 7257

+ 7
- 0
Assets/WebGLTemplates/BetterTemplate/logo.png.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d315c2e7033ee40bc86d677b2255a3f0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 1
- 1
ProjectSettings/EditorBuildSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:81dc2bb76c1a5b7639713c40b44bce40b5757f89e1fe33e7033950ea47e88071
oid sha256:7be799905646e6d7aaab37702ab8e14db03f14e8814c42bb9471fdcb8028125e
size 1282 size 1282

+ 2
- 2
ProjectSettings/ProjectSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:33ce654bd4b3898466537593d9c857378b5209e6a58a289ec29fb28490560b89
size 20897
oid sha256:10e0a66072f7571cd5504c1b3fbbcb9214e19f7d90c8737713b00926e1b56bac
size 20900

Loading…
Cancel
Save