기본 콘텐츠로 건너뛰기

How to integrate with UniWebView2

WWebView is a fully completed module by itself. However, if your game uses UniWebView2 for other platforms (eg. IOS, AOS), you can easily integrate UniWebView2 with the following simple steps.

This document was written based on UniWebView2 version 2.12.0 (Jul 11, 2017).

1. Install UniWebView2

If you import UniWebView2 package to your project, you can see the script files in the project panel as shown below. We will modify this script.

Of course, UniWebView2 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 UniWebView2.





2. Modify UniWebViewPluginMacEditor.cs

Open the script file located in "/Assets/Plugins/UniWebViewPluginMacEditor.cs" and modify UNITY_EDITOR directive to UNITY_EDITOR_OSX as shown below.


3. Add additional directives

Open the script file located in "/Assets/UniWebView/Script/UniWebView.cs" and add following directives.
"UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_WSA"
like this






Modify the following script files in the same way.
  • UseWithCodeSceneManager.cs
  • LocalHTMLSceneManager.cs
  • SizeAndTransitionSceneManager.cs
  • CallbackFromWebSceneManager.cs
  • RunJavaScriptInWebSceneManager.cs

4. Modify UniWebViewHelper.streamingAssetURLForPath

Open the script file located in "/Assets/UniWebView/Script/Helper/UniWebViewHelper.cs" and add following codes in the streamingAssetURLForPath method.

#elif UNITY_STANDALONE_WIN
    return Application.streamingAssetsPath + "/" + path;
#elif UNITY_WSA
    return "ms-appx-web:///Data/StreamingAssets/" + path;

like this












5. 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 "UNIWEBVIEW2_SUPPORTED" define symbol in the "Scripting Define Symbols" field. Be sure to work on each platform's configuration.















6. Let's test it.

Finally, All the integration work is done. please run the demo examples from UniWebView2 to make sure your integration works well.






7. Supported level

WWebView exposes all interfaces of UniWebView2. However, it does not support all features of UniWebView2. For example, UniWebViewPlugin.Show function lets you show the webview with various effects, but the WWebView just shows up. Also, the functions such as ConnectNativeBundle are not supported at all.

The table below explains how well WWebView supports the functionality of UniWebView2.

Method Supported level
Init full
ChangeInsets full
Load full
LoadHTMLString partial
Reload full
Stop full
Show partial
Hide partial
EvaluatingJavaScript full
AddJavaScript full
CleanCache partial
CleanCookie full
GetCookie full
SetCookie full
Destroy full
TransparentBackground full
SetBackgroundColor NOT supported
SetSpinnerShowWhenLoading NOT supported
SetSpinnerText NOT supported
CanGoBack full
CanGoForward full
GoBack full
GoForward full
InputEvent NOT supported
GetId NOT supported
GetCurrentUrl full
ConnectNativeBundle NOT supported
AddUrlScheme full
RemoveUrlScheme full
SetUserAgent full
GetUserAgent full
GetAlpha full
SetAlpha full
GetRenderEventFunc full
ScreenScale NOT supported
SetHeaderField full
SetVerticalScrollBarShow full
SetHorizontalScrollBarShow full
GetOpenLinksInExternalBrowser NOT supported
SetOpenLinksInExternalBrowser NOT supported
SetAllowThirdPartyCookies NOT supported

댓글

이 블로그의 인기 게시물

WWebView - Privacy Policy

Privacy Policy Last modified: August 8, 2017 ICODES STUDIO(“ICODES”) respects the privacy rights of consumers and recognizes the importance of protecting the information collected about you. So we’ve developed a Privacy Policy that covers how we collect, use, disclose, transfer, and store your information. As you use our services, we want you to be clear how we’re using information and the ways in which you can protect your privacy. IF YOU DO NOT AGREE TO THIS POLICY, PLEASE DO NOT USE ANY ICODES SITE, ONLINE OR MOBILE PRODUCT OR SERVICE. Information We Collect We collect information to provide services to all of our users in two ways. Information you give us. Many of our services require you to sign up for a WWebView account. When you do, we’ll ask for personal information, like your name, email address, telephone number. If you want to take full advantage of the sharing features we offer, we might also ask you to create a publicly visible Profile, which may include you...

WWebView Bug reporting

Please leave comments for bugs   On track I want a new bug. Done [1.3.0] Win32: Fixed an issue where the "EnableContextMenu" function called before "Load" did not work properly. [1.3.0] WSA: Fixed a bug "SetUserAgent" does not work on "master" build. [1.2.2] Win32: Fixed a bug that fixed size does not work. [1.2.2] Editor: Fixed a problem where WebView was displayed in the wrong place. [1.2.2] Editor: Fixed invalid focus when the webview hidden. [1.2.2] WSA: fixed an app block on demo scene while navigating. [1.2.2] Win32: fixed GetAlpha() function returns an incorrect value. [1.2.2] Win32: Fixed a problem where TAB & DELETE key did not work. [1.2.1] Editor: GUI Window tried to begin rendering while something else had not finished rendering! Either you have a recursive OnGUI rendering, or the previous OnGUI did not clean up properly. Assertion failed on expression: 'device.IsInsideFrame()' [1.2.1] Editor: Th...

How to integrate with UniWebView3

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). 1. Install UniWebView3 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. 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_...