How to communicate with Unity WebGL app - unity3d

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?

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

Related

how to use google play service in Unity 3D?

I'm working at my new mobile game. The work is going well but when I tried to use google play services at the game, it didn't work by several reasons that I couldn't understand.
There are many guides about using google play service, but still they are all scattered. So I can't totally understand about this.
Could you help me to how to use google play service step by step?
Or link that can solve my problem.
You may check this link for Google Play Games plugin for Unity. This plugin allows you to access the Google Play Games API through Unity's social interface. The plugin provides support for the following features of the Google Play Games API:
sign in
unlock/reveal/increment achievement
post score to leaderboard
cloud save read/write
show built-in achievement/leaderboards UI
events
video recording of gameplay
nearby connections
turn-based multiplayer
real-time multiplayer
To use the plugin, you must first configure your game in the Google Play Developer Console. Follow the instructions on creating a client ID. Be particularly careful when entering your package name and your certificate fingerprints, since mistakes on those screens can be difficult to recover from.
check it
play-unity-plugins
-play billing
-play instant
-play assets delivery
-anfd so on

Embed Unity game within ReactNative (handling bidirectional communication)

I am creating a multi-mobile (iOS/Android) app with React Native.
The app needs to embed & launch a Unity game.
It will need to send information to the game, and also receive information from the game. A function passing a JSON string would be sufficient.
Six years ago I embedded native iOS code within a Unity app and it was rather a dark art.
What is the state of play in 2018?
Presumably it is going to involve separate iOS and Android codebases and a ReactNative component to wrap these, providing a single JavaScript interface. At the Unity end, I'm not sure if it will require separate per-platform coding.

integrate real-time a/v chat into construct 2 game or embed construct 2 into app

I would like to incorporate QuickBlox or Twilio WebRTC chat and A/V calling into the same Angular apps running on a web page or inside a Cordova/Crosswalk app, as a Construct 2 game. I would like to have an audio/video chat running during game play.
Can I embed Construct 2 games into an Ionic view or simple DOM element and then render the video chat over it? Or, should I be integrating the WebRTC chat sessions into Construct 2? Or can I simply display both canvases in the same page?
Thanks in advance.
See: https://quickblox.com/developers/Sample-webrtc-cordova
Junior, here's an answer from the Twilio Video team.
We aren’t investing time in Cordova/Crosswalk right now, although some customers have been asking for it on our GitHub project (https://github.com/twilio/twilio-video.js/issues/85).
twilio-video.js can be integrated into an Angular app easily today. We have a minimal framework test in our GitHub project showing how to set it up (https://github.com/twilio/twilio-video.js/tree/master/test/framework/twilio-video-angular). This isn't a full-fledged application; instead, it's meant to ensure we retain compatibility with Angular as we develop twilio-video.js. It might be nice if we had a more full-fledge Angular Quickstart application in the future, but it gets difficult to support and maintain the various different front-end frameworks (Angular, React, Ember, Meteor, Vue, etc.).
I don’t know much about Construct 2, although it looks like a commercial game engine built on JavaScript/HTML5.
Can I embed Construct 2 games into an Ionic view or simple DOM element and then render the video chat over it?
Yes, this would work.
Or, should I be integrating the WebRTC chat sessions into Construct 2?
This might work, too, assuming Construct 2 allows arbitrary JavaScript inside the game engine.
Or can I simply display both canvases in the same page?
Yes, this would work.
The technique used will depend on how much interaction between the game and the video chat needs to take place. For example, if the lifecycle of the video chat should correspond in some way to in-game elements, then it should be created within Construct 2. If the video chat serves more like a commentary on the game, separate from the gameplay mechanics, then either overlaid or alongside in the same page should work.

How to load 3d object from web server or url in vuforia unity 5.1?

I want to load a 3D object from a URL to a CloudRecoTarget, anyone knows how to do it?
Can you specify your intention more precise? I'm not sure if if get it.
Where is your problem and what kind of technology are you using (App, Server...)?
I guess you want to upload a 3D object, that you are downloading from somewhere of the web, to the Vuforia Cloud Database to create a Vuforia Marker that can be used in Unity for an AR application.
Usually you have a server that handles the communication between the app and the Vuforia API. Your server can simply add a target (your 3d object) to the cloud database and after analysing the target you can download the marker from Vuforia. That's the way I've done it.
Probably you can do this without a server using Unity and C# only. Have a look at the Vuforia API to write you own Vuforia Client in C#. Maybe there is a code snippet somewhere.

Movie making using Google earth COM API

I am trying to programatically generate movie/video file using Google Earth COM APIs (along with Google earth Pro). But unfortunately I could not find any COM APIs to automate movie maker feature in Google earth pro.
Basically my project idea is that: client will provide tour information to server, then some server side service will launch google earth pro locally on server to export tour video to local file, which then will streamed down to client. So client will not need to have google earth plugin installed.
and also as per my knowledge generating movie file using Google earth plugin is not possible (please correct me if I am wrong)
Can anyone point me to some solution?
The Google Earth COM API is being depreciated and developers are being encouraged to use the Google Earth Plugin Api instead.
Using the plug-in in an embedded application would easily allow you to achieve this as you could just capture the frames from the plug-in and then render them to a video file using your desired codec.
I have put together a library of controls that work with the Google Earth Api in managed code. They may not be exactly what you need but they should give some idea of the main principals (e.g. loading, geocoding, screen-grab, etc)