0

I want to implement WebGL model viewer using Unity. This viewer is integrated into existing website. On this website there is a list of models and when user clicks on a model a window pops out displaying this model (like sketchfab). I integrate model viewer which was built with Unity WebGL using

<iframe src="./path-to-unity-webgl-viewer"></iframe>

How can I communicate with the viewer. Is there a way to create some javascript API using Unity which can be accessed from outside Unity app?

1 Answer 1

1

Yes! See: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html

I did this for my games site, https://simmer.io by using SendMessage and JSLib as described in that article. Once you have that communication going, you need to do an additional layer of cross frame communication.

If this is on the same domain as you, it's easy (Communication between iFrames?). If the frames are on separate domains, you use cross domain messaging. See: http://blog.teamtreehouse.com/cross-domain-messaging-with-postmessage

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.