Skip to content

Commit

Permalink
Listen to messages coming from unity.
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunBarad committed Dec 21, 2024
1 parent 752e9fe commit 174ac28
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sim/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace pxsim.unity {

//% blockId=helloUnity block="helloUnity"
export function helloUnity() {
window.addEventListener('message', (event) => {
const command = event.data.unityCommand;
const data = event.data.unityData;
if (!!command) {
console.log(`Received command ${command} from unity with data: ${data}`);
}
});
if (!window.parent) {
console.log('MakeCode: Parent not found');
} else {
Expand Down

0 comments on commit 174ac28

Please sign in to comment.