Can I load local html files by using UniWebView?

Yes, UniWebView can load local html file or any other content a webview supports (images for example). Put your files in the StreamingAssets folder (Assets/StreamingAssets), and use set the url property of UniWebView as below:

For Mac Editor and iOS: _webView.url = Application.streamingAssetsPath + "/yourWebPage.html";

For Android: _webView.url = "file:///android_asset/yourWebPage.html";

If you are using "Split Application Binary" for Android build (obb files), you should not put your local html files under StreamingAssets folder. Instead, you need to put them to Assets/Plugins/Android/assets/ and then you can use the same url (like "file:///android_asset/yourWebPage.html") to load it.

And it has some limitation on Android local file loading. Audio and video files can not be loaded from StreamingAssets folder in Android correctly due to a system bug. A workaround is copying these files to user's external storage (sd card) first, and then load them from there.

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk