add
This commit is contained in:
136
Assets/WebPlayerTemplates/unity-webview/index.html
Normal file
136
Assets/WebPlayerTemplates/unity-webview/index.html
Normal file
@@ -0,0 +1,136 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Unity Web Player | %UNITY_WEB_NAME%</title>
|
||||
%UNITY_UNITYOBJECT_DEPENDENCIES%
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var unityObjectUrl = "%UNITY_UNITYOBJECT_URL%";
|
||||
if (document.location.protocol == 'https:')
|
||||
unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
|
||||
document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
|
||||
-->
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var config = {
|
||||
width: %UNITY_WIDTH%,
|
||||
height: %UNITY_HEIGHT%,
|
||||
params: %UNITY_PLAYER_PARAMS%
|
||||
%UNITY_SET_BASE_DOWNLOAD_URL%
|
||||
};
|
||||
var u = new UnityObject2(config);
|
||||
|
||||
jQuery(function() {
|
||||
|
||||
var $missingScreen = jQuery("#unityPlayer").find(".missing");
|
||||
var $brokenScreen = jQuery("#unityPlayer").find(".broken");
|
||||
$missingScreen.hide();
|
||||
$brokenScreen.hide();
|
||||
|
||||
u.observeProgress(function (progress) {
|
||||
switch(progress.pluginStatus) {
|
||||
case "broken":
|
||||
$brokenScreen.find("a").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
u.installPlugin();
|
||||
return false;
|
||||
});
|
||||
$brokenScreen.show();
|
||||
break;
|
||||
case "missing":
|
||||
$missingScreen.find("a").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
u.installPlugin();
|
||||
return false;
|
||||
});
|
||||
$missingScreen.show();
|
||||
break;
|
||||
case "installed":
|
||||
$missingScreen.remove();
|
||||
break;
|
||||
case "first":
|
||||
break;
|
||||
}
|
||||
});
|
||||
u.initPlugin(jQuery("#unityPlayer")[0], "%UNITY_WEB_PATH%");
|
||||
});
|
||||
-->
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {
|
||||
font-family: Helvetica, Verdana, Arial, sans-serif;
|
||||
background-color: black;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
a:link, a:visited {
|
||||
color: #bfbfbf;
|
||||
}
|
||||
a:active, a:hover {
|
||||
color: #bfbfbf;
|
||||
}
|
||||
p.header {
|
||||
font-size: small;
|
||||
}
|
||||
p.header span {
|
||||
font-weight: bold;
|
||||
}
|
||||
p.footer {
|
||||
font-size: x-small;
|
||||
}
|
||||
div.content {
|
||||
margin: auto;
|
||||
width: %UNITY_WIDTH%px;
|
||||
}
|
||||
div.broken,
|
||||
div.missing {
|
||||
margin: auto;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
width: 193px;
|
||||
}
|
||||
div.broken a,
|
||||
div.missing a {
|
||||
height: 63px;
|
||||
position: relative;
|
||||
top: -31px;
|
||||
}
|
||||
div.broken img,
|
||||
div.missing img {
|
||||
border-width: 0px;
|
||||
}
|
||||
div.broken {
|
||||
display: none;
|
||||
}
|
||||
div#unityPlayer {
|
||||
cursor: default;
|
||||
height: %UNITY_HEIGHT%px;
|
||||
width: %UNITY_WIDTH%px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p class="header"><span>Unity Web Player | </span>%UNITY_WEB_NAME%</p>%UNITY_BETA_WARNING%
|
||||
<div class="content">
|
||||
<div id="unityPlayer">
|
||||
<div class="missing">
|
||||
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
|
||||
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="footer">« created with <a href="http://unity3d.com/unity/" title="Go to unity3d.com">Unity</a> »</p>
|
||||
|
||||
<!-- unity_webview -->
|
||||
<script type="text/javascript" src="unity-webview.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
7
Assets/WebPlayerTemplates/unity-webview/index.html.meta
Normal file
7
Assets/WebPlayerTemplates/unity-webview/index.html.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f9ad43fd49f0415bb3ddcb12d5740df
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/WebPlayerTemplates/unity-webview/thumbnail.png
Normal file
BIN
Assets/WebPlayerTemplates/unity-webview/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b58b041ce3d8f4e07a745943093e4196
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/WebPlayerTemplates/unity-webview/unity-webview.js
Normal file
99
Assets/WebPlayerTemplates/unity-webview/unity-webview.js
Normal file
@@ -0,0 +1,99 @@
|
||||
var unityWebView =
|
||||
{
|
||||
loaded: [],
|
||||
|
||||
init : function (name) {
|
||||
$containers = $('.webviewContainer');
|
||||
if ($containers.length === 0) {
|
||||
$('<div style="position: absolute; left: 0px; width: 100%; height: 100%;"><div class="webviewContainer" style="overflow:hidden; position:relative; width:100%; height:100%; top:-100%; pointer-events:none; z-index: 1;"></div></div')
|
||||
.appendTo($('#unityPlayer'));
|
||||
}
|
||||
var $last = $('.webviewContainer:last');
|
||||
var clonedTop = parseInt($last.css('top')) - 100;
|
||||
var $clone = $last.clone().insertAfter($last).css('top', clonedTop + '%');
|
||||
var $iframe =
|
||||
$('<iframe style="position:relative; width:100%; height100%; border-style:none; display:none; pointer-events:auto;"></iframe>')
|
||||
.attr('id', 'webview_' + name)
|
||||
.appendTo($last)
|
||||
.on('load', function () {
|
||||
$(this).attr('loaded', 'true');
|
||||
var contents = $(this).contents();
|
||||
var w = $(this)[0].contentWindow;
|
||||
contents.find('a').click(function (e) {
|
||||
var href = $.trim($(this).attr('href'));
|
||||
if (href.substr(0, 6) === 'unity:') {
|
||||
u.getUnity().SendMessage(name, "CallFromJS", href.substring(6, href.length));
|
||||
e.preventDefault();
|
||||
} else {
|
||||
w.location.replace(href);
|
||||
}
|
||||
});
|
||||
|
||||
contents.find('form').submit(function () {
|
||||
$this = $(this);
|
||||
var action = $.trim($this.attr('action'));
|
||||
if (action.substr(0, 6) === 'unity:') {
|
||||
var message = action.substring(6, action.length);
|
||||
if ($this.attr('method').toLowerCase() == 'get') {
|
||||
message += '?' + $this.serialize();
|
||||
}
|
||||
u.getUnity().SendMessage(name, "CallFromJS", message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
sendMessage: function (name, message) {
|
||||
u.getUnity().SendMessage(name, "CallFromJS", message);
|
||||
},
|
||||
|
||||
setMargins: function (name, left, top, right, bottom) {
|
||||
var $player = $('#unityPlayer');
|
||||
var width = $player.width();
|
||||
var height = $player.height();
|
||||
|
||||
var lp = left / width * 100;
|
||||
var tp = top / height * 100;
|
||||
var wp = (width - left - right) / width * 100;
|
||||
var hp = (height - top - bottom) / height * 100;
|
||||
|
||||
this.iframe(name)
|
||||
.css('left', lp + '%')
|
||||
.css('top', tp + '%')
|
||||
.css('width', wp + '%')
|
||||
.css('height', hp + '%');
|
||||
},
|
||||
|
||||
setVisibility: function (name, visible) {
|
||||
if (visible)
|
||||
this.iframe(name).show();
|
||||
else
|
||||
this.iframe(name).hide();
|
||||
},
|
||||
|
||||
loadURL: function(name, url) {
|
||||
this.iframe(name).attr('loaded', 'false')[0].contentWindow.location.replace(url);
|
||||
},
|
||||
|
||||
evaluateJS: function (name, js) {
|
||||
$iframe = this.iframe(name);
|
||||
if ($iframe.attr('loaded') === 'true') {
|
||||
$iframe[0].contentWindow.eval(js);
|
||||
} else {
|
||||
$iframe.on('load', function(){
|
||||
$(this)[0].contentWindow.eval(js);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function (name) {
|
||||
this.iframe(name).parent().parent().remove();
|
||||
},
|
||||
|
||||
iframe: function (name) {
|
||||
return $('#webview_' + name);
|
||||
},
|
||||
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 701078ef438644ddabb677ed392d7719
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user