Open frederikw03 opened 4 years ago
Unfortunately you cannot overlay any unity-native UI element, as a native webview is placed over unity's rendering view. (cf. #471, for example).
is there any way to render he webview on a Unity ui element?
In Unity 2019.2 there is in project settings => player => Resolution and Presentation the checkbox for "Render over nativeUI". This works for me on iOS and Android.
@Chriztophaa Thanks!
@Chriztophaa Hello, I hope you can help me. To explain what i did, I made a new project, added a sprite and then added the SampleWebView script to an empty object to get the webview running. Changing the "Render over nativeUI" didn't change anything, the webview works fine but the sprite is always below it. Am i missing something?
Hmm, I tried by myself and with small tweaks for WebView.mm (I only tested the iOS version) a webview was shown behind unity's UI rendering. However, events such as for clicking/dragging didn't be passed to the webview as discussed in https://stackoverflow.com/questions/56018894/android-ios-pass-clicks-on-unityplayer-to-underlying-layout-views . I would also like to know if there is any simple way to solve these issues.
Hey,
I had the same issue. I found the following workaround:
=> change in WebView.mm => do not add the webview, instead insert it at position 0 so that it is placed under the unity view.
=> then you need to extend the unity view and override the following method: https://developer.apple.com/documentation/uikit/uiview/1622533-pointinside If you return NO at a specific point then the click will not be processed by the unity view and will be routed to the underlying webview.
https://developer.apple.com/documentation/uikit/uiview/1622533-pointinside
If we handle events adequately by this method, we need to somehow perform the check for non-rectangle regions, for overlapped buttons such as in https://github.com/gree/unity-webview/issues/503#issue-557065290. We could first capture the whole screen and generate a mask, which is then passed to the extended unity view to check wheter an event location is inside the webview region. Theoretically possible, but complicated... Anyway, thank you:-).
Hello, I'm trying to get that WebView being rendered behind the Unity's UI. I've checked the 'Render over NativeUI' and nothing changed. I've found these WebView.mm (2 files) but have no clue what to edit there to make it work. May I get some directions?
With the following tweak, a webview will be placed behind the unity's view.
diff --git a/plugins/iOS/WebView.mm b/plugins/iOS/WebView.mm
index e01751d..f147b7a 100644
--- a/plugins/iOS/WebView.mm
+++ b/plugins/iOS/WebView.mm
@@ -160,7 +160,7 @@ static NSMutableArray *_instances = [[NSMutableArray alloc] init];
[webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil];
- [view addSubview:webView];
+ [view.superview insertSubview:webView atIndex:0];
return self;
}
Changed it but apparently it (well ofc, it's under iOS plugins) doesn't do for Android. Unity 2019.3.14f1, Android 10
i had to add another manifest into "Assets\Plugins\Android": `<?xml version="1.0" encoding="utf-8"?>
Okay, I think that did the trick. It did the trick so hard that I can't see the WebView at all. Unity's UI elements does not cover entire screen, only about 1/5th of it from the bottom, WebView margins are 0, 5, 0, 50. Camera 'Clear Flags' set to 'Depth only' bc I thought the skybox renders over it but it doesn't do too. The WebView clearly renders bc when closing app I can see loaded page for just milliseconds. Any ideas?
i have the camera background set to a solid colour and the colour needs to have 0 for the alpha channel. You also need to have "Render over native UI" set in the android player settings under Resolution and presentation settings.
Render over native UI was already set to true. Solid color doesn't work too...
I investigated further and uploaded an experimental implementation #584. If you are still interested in, could you please have a try.
Will this work on the unity editor as well?
@UnityDev524 No, it doesn't work on Unity Editor.
Is there an easy way to get the webview behind some UI in my scene?
i want it to be in the white space