-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webview behind UI #503
Comments
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: |
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 #503 (comment). 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. |
i had to add another manifest into "Assets\Plugins\Android": |
Okay, I think that did the trick. |
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. |
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
The text was updated successfully, but these errors were encountered: