UnityOculusAndroidVRBrowser icon indicating copy to clipboard operation
UnityOculusAndroidVRBrowser copied to clipboard

Receiving a message from browser.

Open srcnalt opened this issue 4 years ago • 7 comments

Hi,

I was wondering if it's possible to receive a message from web content to Unity project with the plugin.

srcnalt avatar May 05 '21 13:05 srcnalt

Seems like this is kind of related to this question here https://github.com/IanPhilips/UnityOculusAndroidVRBrowser/issues/13

srcnalt avatar May 05 '21 13:05 srcnalt

Receive a message? What type of message? The Gecko Engine passes information back to Unity via callbacks, defined here on the java side and redefined (not DRY I know :( but I think this is the only way to do it) on the receiving end here on the C# side.

IanPhilips avatar May 05 '21 19:05 IanPhilips

Hi, what I mean is sending a message to Unity, from the browser.

I am using unity-webview repo for displaying a browser window in Android and IOS apps, however it does not support VR. I was looking for alternatives and came up with this project which works perfect!

In unity-webview the user can add a line of code into their webpage, such as Unity.call("message") and this message is captured by the plugin and served to user. I was wondering if something similar would be possible here.

I suppose this is done by somehow parsing the javascript in the page and injecting a functionality to a certain Unity object in there.

srcnalt avatar May 06 '21 07:05 srcnalt

Ohhh right right, this is complicated. What you want to do is interact with GeckoView/one of its components from javascript. That should give you the right search queries. This may be of use.

IanPhilips avatar May 06 '21 19:05 IanPhilips

reference: https://github.com/mozilla/geckoview/issues/85

IanPhilips avatar May 06 '21 19:05 IanPhilips

Thank you, I'll give it a read.

srcnalt avatar May 06 '21 22:05 srcnalt

Looks like #41 used WebExtension for this

IanPhilips avatar Dec 09 '21 00:12 IanPhilips