push iniziale del progetto
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
rpmHideButton.onclick = function () {
|
||||
if (document.fullscreenElement) {
|
||||
canvasWrapper.requestFullscreen();
|
||||
}
|
||||
rpmContainer.style.display = "none";
|
||||
};
|
||||
|
||||
function setupRpmFrame(url, targetGameObjectName) {
|
||||
const message = "message";
|
||||
const rpmFilter = "readyplayerme";
|
||||
const frameReadyEvent = "v1.frame.ready";
|
||||
const receivingFunctionName = "FrameMessageReceived";
|
||||
|
||||
rpmFrame.src = "";
|
||||
rpmFrame.src = url;
|
||||
window.removeEventListener(message, subscribe);
|
||||
document.removeEventListener(message, subscribe);
|
||||
window.addEventListener(message, subscribe);
|
||||
document.addEventListener(message, subscribe);
|
||||
|
||||
function subscribe(event) {
|
||||
const json = parse(event);
|
||||
if (
|
||||
unityGame == null ||
|
||||
json?.source !== rpmFilter ||
|
||||
json?.eventName == null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
unityGame.SendMessage(
|
||||
targetGameObjectName,
|
||||
receivingFunctionName,
|
||||
event.data
|
||||
);
|
||||
|
||||
// Subscribe to all events sent from Ready Player Me once frame is ready
|
||||
if (json.eventName === frameReadyEvent) {
|
||||
if (rpmFrame.contentWindow) {
|
||||
rpmFrame.contentWindow.postMessage(
|
||||
JSON.stringify({
|
||||
target: rpmFilter,
|
||||
type: "subscribe",
|
||||
eventName: "v1.**",
|
||||
}),
|
||||
"*"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get user id
|
||||
if (json.eventName === "v1.user.set") {
|
||||
console.log(`FRAME: User with id ${json.data.id} set: ${JSON.stringify(json)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function parse(event) {
|
||||
try {
|
||||
return JSON.parse(event.data);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showRpm() {
|
||||
rpmContainer.style.display = "block";
|
||||
}
|
||||
|
||||
function hideRpm() {
|
||||
rpmContainer.style.display = "none";
|
||||
rpmFrame.src = rpmFrame.src;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6a51c32164f4f89bfe48b53b9b277e5
|
||||
timeCreated: 1651665285
|
||||
@@ -0,0 +1,3 @@
|
||||
var rpmFrame = document.getElementById("rpm-frame");
|
||||
var rpmContainer = document.getElementById("rpm-container");
|
||||
var rpmHideButton = document.getElementById("rpm-hide-button");
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cac29b0412dc4c48a52583c020b2328a
|
||||
timeCreated: 1683195317
|
||||
@@ -0,0 +1,54 @@
|
||||
#rpm-container
|
||||
{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position:absolute;
|
||||
display:none;
|
||||
pointer-events: inherit;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2753095d48c49359f70946fe805a20a
|
||||
timeCreated: 1683194886
|
||||
Reference in New Issue
Block a user