diff --git a/dist/package-nofragment/Assets/Plugins/Android/WebViewPlugin.aar b/dist/package-nofragment/Assets/Plugins/Android/WebViewPlugin.aar index 415284cf..a79fa1bb 100644 Binary files a/dist/package-nofragment/Assets/Plugins/Android/WebViewPlugin.aar and b/dist/package-nofragment/Assets/Plugins/Android/WebViewPlugin.aar differ diff --git a/dist/package-nofragment/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs b/dist/package-nofragment/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs index cb0c138a..4c370418 100644 --- a/dist/package-nofragment/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs +++ b/dist/package-nofragment/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs @@ -75,6 +75,8 @@ public void OnPostGenerateGradleAndroidProject(string basePath) { } } } + changed = (androidManifest.SetApplicationTheme("@style/UnityThemeSelector") || changed); + changed = (androidManifest.SetActivityTheme("@style/UnityThemeSelector.Translucent") || changed); changed = (androidManifest.SetHardwareAccelerated(true) || changed); #if UNITYWEBVIEW_ANDROID_USES_CLEARTEXT_TRAFFIC changed = (androidManifest.SetUsesCleartextTraffic(true) || changed); @@ -302,6 +304,25 @@ internal bool SetUsesCleartextTraffic(bool enabled) { return changed; } + internal bool SetApplicationTheme(string theme) { + bool changed = false; + if (ApplicationElement.GetAttribute("theme", AndroidXmlNamespace) != theme) { + ApplicationElement.SetAttribute("theme", AndroidXmlNamespace, theme); + changed = true; + } + return changed; + } + + internal bool SetActivityTheme(string theme) { + bool changed = false; + var activity = GetActivityWithLaunchIntent() as XmlElement; + if (activity.GetAttribute("theme", AndroidXmlNamespace) != theme) { + activity.SetAttribute("theme", AndroidXmlNamespace, theme); + changed = true; + } + return changed; + } + internal bool SetHardwareAccelerated(bool enabled) { bool changed = false; var activity = GetActivityWithLaunchIntent() as XmlElement; diff --git a/dist/package-nofragment/Assets/Plugins/iOS/WebView.mm b/dist/package-nofragment/Assets/Plugins/iOS/WebView.mm index f89d5fea..f4ffb604 100644 --- a/dist/package-nofragment/Assets/Plugins/iOS/WebView.mm +++ b/dist/package-nofragment/Assets/Plugins/iOS/WebView.mm @@ -260,7 +260,7 @@ - (id)initWithGameObjectName:(const char *)gameObjectName_ transparent:(BOOL)tra [webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil]; - [view addSubview:webView]; + [view.superview insertSubview:webView atIndex:0]; return self; } diff --git a/dist/package-nofragment/Assets/Plugins/iOS/WebViewWithUIWebView.mm b/dist/package-nofragment/Assets/Plugins/iOS/WebViewWithUIWebView.mm index b6ec79c3..246de7a8 100644 --- a/dist/package-nofragment/Assets/Plugins/iOS/WebViewWithUIWebView.mm +++ b/dist/package-nofragment/Assets/Plugins/iOS/WebViewWithUIWebView.mm @@ -320,7 +320,7 @@ - (id)initWithGameObjectName:(const char *)gameObjectName_ transparent:(BOOL)tra [webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil]; - [view addSubview:webView]; + [view.superview insertSubview:webView atIndex:0]; return self; } diff --git a/dist/package/Assets/Plugins/Android/WebViewPlugin.aar b/dist/package/Assets/Plugins/Android/WebViewPlugin.aar index 03e871d5..9d3b6cfb 100644 Binary files a/dist/package/Assets/Plugins/Android/WebViewPlugin.aar and b/dist/package/Assets/Plugins/Android/WebViewPlugin.aar differ diff --git a/dist/package/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs b/dist/package/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs index 03644a05..7257c770 100644 --- a/dist/package/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs +++ b/dist/package/Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs @@ -75,6 +75,8 @@ public void OnPostGenerateGradleAndroidProject(string basePath) { } } } + changed = (androidManifest.SetApplicationTheme("@style/UnityThemeSelector") || changed); + changed = (androidManifest.SetActivityTheme("@style/UnityThemeSelector.Translucent") || changed); changed = (androidManifest.SetHardwareAccelerated(true) || changed); #if UNITYWEBVIEW_ANDROID_USES_CLEARTEXT_TRAFFIC changed = (androidManifest.SetUsesCleartextTraffic(true) || changed); @@ -302,6 +304,25 @@ internal bool SetUsesCleartextTraffic(bool enabled) { return changed; } + internal bool SetApplicationTheme(string theme) { + bool changed = false; + if (ApplicationElement.GetAttribute("theme", AndroidXmlNamespace) != theme) { + ApplicationElement.SetAttribute("theme", AndroidXmlNamespace, theme); + changed = true; + } + return changed; + } + + internal bool SetActivityTheme(string theme) { + bool changed = false; + var activity = GetActivityWithLaunchIntent() as XmlElement; + if (activity.GetAttribute("theme", AndroidXmlNamespace) != theme) { + activity.SetAttribute("theme", AndroidXmlNamespace, theme); + changed = true; + } + return changed; + } + internal bool SetHardwareAccelerated(bool enabled) { bool changed = false; var activity = GetActivityWithLaunchIntent() as XmlElement; diff --git a/dist/package/Assets/Plugins/iOS/WebView.mm b/dist/package/Assets/Plugins/iOS/WebView.mm index f89d5fea..f4ffb604 100644 --- a/dist/package/Assets/Plugins/iOS/WebView.mm +++ b/dist/package/Assets/Plugins/iOS/WebView.mm @@ -260,7 +260,7 @@ - (id)initWithGameObjectName:(const char *)gameObjectName_ transparent:(BOOL)tra [webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil]; - [view addSubview:webView]; + [view.superview insertSubview:webView atIndex:0]; return self; } diff --git a/dist/package/Assets/Plugins/iOS/WebViewWithUIWebView.mm b/dist/package/Assets/Plugins/iOS/WebViewWithUIWebView.mm index b6ec79c3..246de7a8 100644 --- a/dist/package/Assets/Plugins/iOS/WebViewWithUIWebView.mm +++ b/dist/package/Assets/Plugins/iOS/WebViewWithUIWebView.mm @@ -320,7 +320,7 @@ - (id)initWithGameObjectName:(const char *)gameObjectName_ transparent:(BOOL)tra [webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil]; - [view addSubview:webView]; + [view.superview insertSubview:webView atIndex:0]; return self; } diff --git a/dist/unity-webview-nofragment.unitypackage b/dist/unity-webview-nofragment.unitypackage index 8a1cf5f2..d9d7bb4d 100644 Binary files a/dist/unity-webview-nofragment.unitypackage and b/dist/unity-webview-nofragment.unitypackage differ diff --git a/dist/unity-webview-nofragment.zip b/dist/unity-webview-nofragment.zip index ded01c96..16c0417d 100644 Binary files a/dist/unity-webview-nofragment.zip and b/dist/unity-webview-nofragment.zip differ diff --git a/dist/unity-webview.unitypackage b/dist/unity-webview.unitypackage index feda313a..a4d62471 100644 Binary files a/dist/unity-webview.unitypackage and b/dist/unity-webview.unitypackage differ diff --git a/dist/unity-webview.zip b/dist/unity-webview.zip index f5aaee4f..7e04ac37 100644 Binary files a/dist/unity-webview.zip and b/dist/unity-webview.zip differ