移动端测试
12
Assets/WebGLTemplates/RPM_2019/TemplateData/Global.js
Normal file
@ -0,0 +1,12 @@
|
||||
var rpmFrame = document.getElementById("rpm-frame");
|
||||
var rpmContainer = document.getElementById("rpm-container");
|
||||
var container = document.querySelector("#unity-container");
|
||||
var canvas = document.querySelector("#unity-canvas");
|
||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
||||
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
||||
var warningBanner = document.querySelector("#unity-warning");
|
||||
var rpmHideButton = document.getElementById("rpm-hide-button");
|
||||
var canvasWrapper = document.getElementById("canvas-wrap");
|
||||
var unityGame;
|
||||
var partner;
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99f6d767a95b480aada97df26abe70b0
|
||||
timeCreated: 1651665858
|
@ -0,0 +1,68 @@
|
||||
function setupRpmFrame(subdomain) {
|
||||
rpmFrame.src = `https://${subdomain !== "" ? subdomain : "demo"}.readyplayer.me/avatar?frameApi`
|
||||
window.addEventListener("message", subscribe);
|
||||
document.addEventListener("message", subscribe);
|
||||
function subscribe(event) {
|
||||
const json = parse(event);
|
||||
if (
|
||||
unityGame == null ||
|
||||
json?.source !== "readyplayerme" ||
|
||||
json?.eventName == null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
unityGame.SendMessage(
|
||||
"DebugPanel",
|
||||
"LogMessage",
|
||||
`Event: ${json.eventName}`
|
||||
);
|
||||
|
||||
// Susbribe to all events sent from Ready Player Me once frame is ready
|
||||
if (json.eventName === "v1.frame.ready") {
|
||||
rpmFrame.contentWindow.postMessage(
|
||||
JSON.stringify({
|
||||
target: "readyplayerme",
|
||||
type: "subscribe",
|
||||
eventName: "v1.**",
|
||||
}),
|
||||
"*"
|
||||
);
|
||||
}
|
||||
|
||||
// Get avatar GLB URL
|
||||
if (json.eventName === "v1.avatar.exported") {
|
||||
rpmContainer.style.display = "none";
|
||||
unityGame.SendMessage(
|
||||
"WebAvatarLoader",
|
||||
"OnWebViewAvatarGenerated",
|
||||
json.data.url
|
||||
);
|
||||
console.log(`Avatar URL: ${json.data.url}`);
|
||||
}
|
||||
|
||||
// Get user id
|
||||
if (json.eventName === "v1.user.set") {
|
||||
console.log(`User with id ${json.data.id} set: ${JSON.stringify(json)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function parse(event) {
|
||||
try {
|
||||
return JSON.parse(event.data);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayRpm() {
|
||||
rpmContainer.style.display = "block";
|
||||
}
|
||||
|
||||
function hideRpm() {
|
||||
rpmContainer.style.display = "none";
|
||||
}
|
||||
|
||||
function showFullscreen(){
|
||||
canvasWrapper.requestFullscreen();
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a1ae643b03e43dc85c51be979193a4c
|
||||
timeCreated: 1651663700
|
24
Assets/WebGLTemplates/RPM_2019/TemplateData/UnityProgress.js
Normal file
@ -0,0 +1,24 @@
|
||||
function UnityProgress(unityInstance, progress) {
|
||||
if (!unityInstance.Module)
|
||||
return;
|
||||
if (!unityInstance.logo) {
|
||||
unityInstance.logo = document.createElement("div");
|
||||
unityInstance.logo.className = "logo " + unityInstance.Module.splashScreenStyle;
|
||||
unityInstance.container.appendChild(unityInstance.logo);
|
||||
}
|
||||
if (!unityInstance.progress) {
|
||||
unityInstance.progress = document.createElement("div");
|
||||
unityInstance.progress.className = "progress " + unityInstance.Module.splashScreenStyle;
|
||||
unityInstance.progress.empty = document.createElement("div");
|
||||
unityInstance.progress.empty.className = "empty";
|
||||
unityInstance.progress.appendChild(unityInstance.progress.empty);
|
||||
unityInstance.progress.full = document.createElement("div");
|
||||
unityInstance.progress.full.className = "full";
|
||||
unityInstance.progress.appendChild(unityInstance.progress.full);
|
||||
unityInstance.container.appendChild(unityInstance.progress);
|
||||
}
|
||||
unityInstance.progress.full.style.width = (100 * progress) + "%";
|
||||
unityInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
|
||||
if (progress == 1)
|
||||
unityInstance.logo.style.display = unityInstance.progress.style.display = "none";
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba1998936af887c45984139e37d7e71e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
function setupUnity(loaderUrl, buildUrl){
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = loaderUrl;
|
||||
script.onload = () => {
|
||||
unityGame = UnityLoader.instantiate("unity-container", buildUrl, {onProgress: UnityProgress});
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffa77f826c41493f9d4a68fa3c72f81a
|
||||
timeCreated: 1651663768
|
BIN
Assets/WebGLTemplates/RPM_2019/TemplateData/favicon.ico
Normal file
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e70dc1ba0d395f8429405f6744cd190f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/WebGLTemplates/RPM_2019/TemplateData/fullscreen.png
Normal file
After Width: | Height: | Size: 345 B |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb99c28e8ab437d4ea9cb078105d3bd5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 155 B |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f63003f99553a694cb6bd062e67eed87
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 159 B |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ff4d97cc3c48f34388d4fe3c5801e3f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 137 B |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba74707f5327b664f8985b4d1869c882
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 142 B |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4ccd9b87ea85044ea91daa746efff30
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f8aaf5bd7ddc84da89366bae9acfc0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae8372d18a0867c47b5db317df961999
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
109
Assets/WebGLTemplates/RPM_2019/TemplateData/style.css
Normal file
@ -0,0 +1,109 @@
|
||||
#webgl-content * {border: 0; margin: 0; padding: 0}
|
||||
#webgl-content {position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
|
||||
|
||||
#webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
|
||||
#webgl-content .logo {background: url('progressLogo.Light.png') no-repeat center / contain; width: 154px; height: 130px;}
|
||||
#webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
|
||||
#webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
|
||||
#webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}
|
||||
|
||||
#webgl-content .logo.Dark {background-image: url('progressLogo.Dark.png');}
|
||||
#webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
|
||||
#webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}
|
||||
|
||||
#webgl-content .footer {margin-top: 5px; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
|
||||
#webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
|
||||
#webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
|
||||
#webgl-content .footer .title {margin-right: 10px; float: right;}
|
||||
#webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}
|
||||
|
||||
#canvas-wrap {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
#rpm-container
|
||||
{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position:absolute;
|
||||
display:none;
|
||||
pointer-events: inherit;
|
||||
z-index:10;
|
||||
}
|
||||
|
||||
.rpm-frame {
|
||||
width: 100%;
|
||||
height: 95%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans,
|
||||
Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
display:block;
|
||||
pointer-events: inherit;
|
||||
}
|
||||
|
||||
#rpm-hide-button {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 5%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans,
|
||||
Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
color:#000;
|
||||
background-color: #e2e3ec;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
box-shadow: inset 0px 0px 8px 2px rgba(0,0,0,0.2);
|
||||
pointer-events: inherit;
|
||||
}
|
||||
|
||||
#rpm-hide-button:hover {
|
||||
background-color: #f1f2fa;
|
||||
}
|
||||
|
||||
#rpm-hide-button:Active {
|
||||
background-color: #e2e3ec;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background-color: #b4b6c5;
|
||||
padding: 3px;
|
||||
border-radius: 5px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#page-title {
|
||||
padding: 20px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans,
|
||||
Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#webgl-content.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
|
||||
#webgl-content.unity-mobile { width: 100%!important; height: 100%!important; }
|
||||
#unity-container {background-color: #ffffff!important;}
|
||||
|
||||
/*Default Unity styles*/
|
||||
body { padding: 0; margin: 0 }
|
||||
#webgl-content { position: absolute;pointer-events: inherit; }
|
||||
#webgl-content.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
|
||||
#webgl-content.unity-mobile { width: 100%; height: 100% }
|
||||
#unity-container { background: #231F20;pointer-events: inherit; display:block; width: 100%!important ; height: 100%!important }
|
||||
.unity-mobile #unity-canvas { width: 100%; height: 100% }
|
||||
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
|
||||
#unity-footer { position: relative }
|
||||
.unity-mobile #unity-footer { display: none }
|
||||
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
|
||||
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
|
||||
#unity-mobile-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34ee122efdd297f4b98624bf8eb7921b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/WebGLTemplates/RPM_2019/TemplateData/webgl-logo.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74656721bfc39fa45a20d1393e9296fb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|