FAQ

Common WebView issues and solutions

Why doesn't WebView work in Unity Editor?

WebView requires native iOS WKWebView or Android WebView components which are not available in Unity Editor. All WebView testing must be done on physical devices. Build and deploy to iOS or Android to test web view functionality.

How do I get data from WebView to Unity?

Use custom URL schemes for web-to-Unity communication:

// In Unity: Register custom scheme
webView.AddURLScheme("mygame");

// In HTML: Use custom URL to send data
<button onclick='window.location="mygame://action?data=value"'>Send to Unity</button>

// In Unity: Receive the URL
void OnURLSchemeMatchFound(string url)
{
    Debug.Log($"Received from web: {url}");
    // Parse URL parameters and take action
}

For complex data, pass JSON as URL parameters and parse in Unity.

HTTP URLs don't load on iOS. How do I fix this?

iOS App Transport Security (ATS) blocks HTTP URLs by default. Solutions:

Option 1 (Recommended): Use HTTPS URLs

Option 2: Add ATS exception to Info.plist for specific domains (requires Xcode configuration)

Option 3: Disable ATS entirely (not recommended for production - security risk)

Can I display multiple WebViews at once?

No. Essential Kit supports one active web view at a time. Creating a new instance replaces any existing web view. If you need to switch between different web content:

JavaScript doesn't execute. What should I check?

Ensure JavaScript is enabled before running scripts:

Also verify:

  • Page is fully loaded before executing JavaScript (wait for OnLoadFinish)

  • JavaScript code syntax is correct

  • Web view is visible (Show() called)

How do I check the loading progress of a page?

Monitor the Progress property and IsLoading state:

Can I customize the native WebView interface?

WebView styles are limited to three options: Default, Popup, and Browser. You cannot fully customize the native interface appearance. For custom UI:

  • Use Default style (no controls)

  • Build your own Unity UI controls

  • Control web view via scripts (Show(), Hide(), Reload(), etc.)

Web page displays incorrectly (zoomed in/out). How do I fix this?

Enable page scaling:

Also ensure your HTML includes proper viewport meta tag:

How do I pass complex data from JavaScript to Unity?

Use JSON encoding in JavaScript and parse in Unity:

Does WebView support cookies and local storage?

Yes, WebView supports cookies, local storage, and session storage. Data persists between web view sessions unless you call ClearCache().

To manually clear all web data:

Note: ClearCache() affects all web view instances globally.

Can WebView play videos and audio?

Yes, WebView supports HTML5 video and audio playback. For best results:

  • Use standard HTML5 <video> and <audio> tags

  • Provide multiple formats for compatibility (MP4, WebM)

  • For Android: Enable microphone permission if using audio input

  • Test autoplay behavior (some platforms block autoplay)

How do I handle the Android back button?

Configure back button behavior in Essential Kit Settings:

Default Behavior (recommended): Back button hides web view

Browser Behavior: Back button navigates to previous page

You can also handle back button programmatically by detecting OnHide event.

Web content loads slowly. How can I improve performance?

Optimize web view performance:

  1. Show Loading Indicator: Display progress while loading

  1. Optimize Web Content:

  • Compress images before serving

  • Minimize JavaScript and CSS

  • Use CDN for external resources

  • Enable browser caching headers

  1. Preload Critical Content: Load frequently used pages in background

  2. Clear Old Cache Periodically:

Can I load local HTML files from StreamingAssets?

Yes, use FileURLWithPath:

Android Note: StreamingAssets are compressed in APK. For complex HTML with relative resources, copy to persistentDataPath first:

Where can I confirm plugin behavior versus my implementation?

Run Assets/Plugins/VoxelBusters/EssentialKit/Examples/Scenes/WebViewDemo.unity on a physical device. If the sample works but your implementation doesn't:

  • Compare frame setup (did you call SetFullScreen() or set Frame?)

  • Verify Show() is called before expecting web view to appear

  • Check event registration (subscribe before loading content)

  • Confirm JavaScript is enabled before calling RunJavaScript()

  • Validate URL format (HTTPS for iOS, proper scheme for custom URLs)

Can I intercept all URL navigation in WebView?

No direct interception of all URLs, but you can:

  1. Register specific custom URL schemes with AddURLScheme()

  2. Monitor OnLoadStart event for URL changes

  3. Use JavaScript to control navigation and communicate with Unity

How do I handle OAuth login flows?

Implement OAuth redirect with custom URL scheme:

Last updated

Was this helpful?