gree / unity-webview

zlib License
2.23k stars 684 forks source link

cannot render webview in GearVR handset #81

Open geoabensur opened 8 years ago

geoabensur commented 8 years ago

I would like to know if unity-webview has support to render pages in VR handsets like GearVR. I have included this plugin in my unity VR app and webview was not rendered properly. Is there any plan to include it as texture or something like that? Thank you very much

KojiNakamaru commented 8 years ago

This plugin overlays system-provided webviews as is on unity's rendering and doesn't support the side-by-side/spherically-distorted display. An easy way might be to prepare some special web pages (cf. http://through-the-interface.typepad.com/through_the_interface/2015/01/integrating-web-based-vr-samples-into-a-native-google-cardboard-app-using-the-cardboard-sdk-for-android.html ). We could extend the plugin to generate webview textures as below, theoretically, but it would take long and the implementation would tend to be tricky...

  1. prepare a webview instance not attached to the activity's view.
  2. call webview.onTouchEvent(event), etc. to pump (pseudo) events
  3. call webview.draw(canvas) to generate a bitmap (cf. http://stackoverflow.com/questions/31344667/creating-bitmap-from-webview-with-content-offscreen-android )
  4. pass tex.GetNativeTexturePtr() to the plugin and call GLES20.glTexImage2D() for the bitmap.
  5. go to 2.
KojiNakamaru commented 8 years ago

https://www.assetstore.unity3d.com/jp/#!/content/29346 EasyWebViewTexture For Android

Though I haven't tested, this might help.

IanPhilips commented 5 years ago

working on this project for android, it's a bit slow because it uses the cpu but hopefully will transfer to the GPU in the future. Btw, thanks @KojiNakamaru for the tips above, I followed them closely except the OpenGL stuff which will come in the future.

KojiNakamaru commented 5 years ago

@IanPhilips Thank you for sharing a nice project. Though you may already know, the followings should be useful to proceed further (I bookmarked them before but haven't been able to try yet).

https://coderwall.com/p/6koh_g/rendering-any-android-view-directly-to-an-opengl-texture https://github.com/ArtemBogush/AndroidViewToGLRendering

clovelt commented 2 years ago

Been looking at these links, super useful! No progress yet, though. Any interest in pursuing 3D+VR rendering?

KojiNakamaru commented 2 years ago

For other solutions, you can check https://github.com/gree/unity-webview/issues/612#issuecomment-724541385.

IanPhilips commented 2 years ago

Just got pinged with the comment updates, my project works very well now. It's no longer based on the cpu and instead uses the gpu. You can watch videos, etc. in 3D. https://github.com/IanPhilips/UnityOculusAndroidVRBrowser

clovelt commented 2 years ago

Just got pinged with the comment updates, my project works very well now. It's no longer based on the cpu and instead uses the gpu. You can watch videos, etc. in 3D. https://github.com/IanPhilips/UnityOculusAndroidVRBrowser

Hey Ian! I discovered your project not very long after my comment, do you have any contact information? I made a UI and keyboard for it

IanPhilips commented 2 years ago

@clovelt any reason you can't submit a PR or issue on the repo? iansphilips@gmail.com

HafizMSaad commented 4 months ago

https://www.assetstore.unity3d.com/jp/#!/content/29346 @KojiNakamaru this link is either broken or somehow not working for me.

HafizMSaad commented 4 months ago

@geoabensur Could you please clarify what you mean by 'not rendered properly'? I'm encountering a series of errors when loading the sample(SampleWebView) scene from another scene on Quest 2:

NullReferenceException: Object reference not set to an instance of an object. at UnityEngine.Transform.TransformPoint (UnityEngine.Vector3 position) [0x00000] in <00000000000000000000000000000000>:0 at Oculus.Interaction.Input.TrackingToWorldTransformerOVR.ToWorldPose (UnityEngine.Pose pose) [0x00000] in <00000000000000000000000000000000>:0 at Oculus.Interaction.Input.Controller.TryGetPose (UnityEngine.Pose& pose) [0x00000] in <00000000000000000000000000000000>:0 at Oculus.Interaction.Input.Visuals.OVRControllerVisual.HandleUpdated () [0x00000] in <00000000000000000000000000000000>:0

NullReferenceException: Object reference not set to an instance of an object. at SampleWebView.b__3_0 (System.String msg) [0x00000] in <00000000000000000000000000000000>:0 at WebViewObject.Update () [0x00000] in <00000000000000000000000000000000>:0

NullReferenceException: Object reference not set to an instance of an object. at SampleWebView.b__3_0 (System.String msg) [0x00000] in <00000000000000000000000000000000>:0 at WebViewObject.Update () [0x00000] in <00000000000000000000000000000000>:0

HafizMSaad commented 4 months ago

For those seeking VR-compatible solutions, I recommend checking out the following repository: https://github.com/TLabAltoh/TLabWebViewVR