WWebView is a fully completed module by itself. However, if your game uses UniWebView3 for other platforms (eg. IOS, AOS), you can easily integrate UniWebView3 with the following simple steps.
This document was written based on UniWebView3 version 3.3.2 (Oct 09, 2017).
If you import UniWebView3 package to your project, you can see the script files in the project panel as shown below. We will modify this script.
Of course, UniWebView3 is configured with script code that does not support Windows Unity Editor, Windows Standalone and Windows Store platform. That's why we need to modify the script files of UniWebView3.
#if !UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX && !UNITY_IOS && !UNITY_ANDROID && !UNITY_EDITOR_WIN && !UNITY_STANDALONE_WIN && !UNITY_WSA
like this
The table below explains how well WWebView supports the functionality of UniWebView3.
This document was written based on UniWebView3 version 3.3.2 (Oct 09, 2017).
1. Install UniWebView3
Of course, UniWebView3 is configured with script code that does not support Windows Unity Editor, Windows Standalone and Windows Store platform. That's why we need to modify the script files of UniWebView3.
2. Modify UniWebViewPlaceholder.cs
Open the script file located in "/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs" and modify directives as shown below.#if !UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX && !UNITY_IOS && !UNITY_ANDROID && !UNITY_EDITOR_WIN && !UNITY_STANDALONE_WIN && !UNITY_WSA
like this
3. Modify UniWebViewHelper.StreamingAssetURLForPath
Open the script file located in "/Assets/UniWebView/Script/UniWebViewHelper.cs" and add following codes in the StreamingAssetURLForPath method.
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
return Application.streamingAssetsPath + "/" + path;
#elif UNITY_WSA
return "ms-appx-web:///Data/StreamingAssets/" + path;
like this
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
return Application.streamingAssetsPath + "/" + path;
#elif UNITY_WSA
return "ms-appx-web:///Data/StreamingAssets/" + path;
like this
4. Update Unity's Player Settings
From the Unity top menu, select "Edit/Project Settings/Player". This will show PlayerSettings window. In the inspector, expand "Other Settings" panel and add "UNIWEBVIEW3_SUPPORTED" define symbol in the "Scripting Define Symbols" field. Be sure to work on each platform's configuration.5. Let's test it.
Finally, All the integration work is done. please run the demo examples from UniWebView3 to make sure your integration works well.7. Supported level
WWebView exposes all interfaces of UniWebView3. However, it does not support all features of UniWebViewe3. For example, UniWebViewPlugin.Show function lets you show the webview with various effects, but the WWebView just shows up. Also, the functions such as SetShowToolbar are not supported at all.The table below explains how well WWebView supports the functionality of UniWebView3.
Method | Supported level |
---|---|
Init | full |
SetLogLevel | NOT supported |
Destroy | full |
Load | partial |
LoadHTMLString | partial |
Reload | full |
Stop | full |
GetUrl | full |
SetFrame | full |
SetPosition | full |
SetSize | full |
Show | partial |
Hide | partial |
AnimateTo | NOT supported |
AddJavaScript | partial |
EvaluateJavaScript | partial |
AddUrlScheme | full |
RemoveUrlScheme | full |
AddSslExceptionDomain | NOT supported |
RemoveSslExceptionDomain | NOT supported |
SetHeaderField | full |
SetUserAgent | full |
GetUserAgent | full |
SetAllowAutoPlay | NOT supported |
SetAllowInlinePlay | NOT supported |
SetAllowJavaScriptOpenWindow | NOT supported |
SetJavaScriptEnabled | NOT supported |
CleanCache | full |
ClearCookies | full |
SetCookie | partial |
GetCookie | partial |
ClearHttpAuthUsernamePassword | NOT supported |
SetBackgroundColor | NOT supported |
SetWebViewAlpha | full |
GetWebViewAlpha | full |
SetShowSpinnerWhileLoading | NOT supported |
SetSpinnerText | NOT supported |
CanGoBack | full |
CanGoForward | full |
GoBack | full |
GoForward | full |
SetOpenLinksInExternalBrowser | NOT supported |
SetHorizontalScrollBarEnabled | full |
SetVerticalScrollBarEnabled | full |
SetBouncesEnabled | NOT supported |
SetZoomEnabled | NOT supported |
SetShowToolbar | NOT supported |
SetToolbarDoneButtonText | NOT supported |
SetWebContentsDebuggingEnabled | NOT supported |
댓글
댓글 쓰기