WebViewHook
WebViewHook copied to clipboard
WebView content disappears when the window is docked
Despite images in Readme show docked windows with content, in practice when the window is docked its webview content disappears forever (undocking does not return it back). Tested in Unity 2018.4.13

I'm experiencing the same issue.
Yes, I tested this nice code on Unity 2019 and it has an issue when you dock the window. The webview seems to disappear. The problem is that the webview still exists and is fully working, but seems to lose the right position inside the Unity interface, so it is located outside the Editor Window. I tried to resolve this issue by myself, but I don't know how to force the webview to be correctly displayed.
However, this is a possible solution, even if it's not perfect:
In the WebWindow (the Editor), add a bool variable: bool refresh = true;
Then, in the OnGUI() under the if (ev.type == EventType.Repaint), after the webView.OnGUI... add:
BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; MethodInfo isDockedMethod = typeof(EditorWindow).GetProperty("docked", fullBinding).GetGetMethod(true); bool isDocked = (bool)isDockedMethod.Invoke(this, null);
if (isDocked)
{
if (refresh)
{
refresh = false;
DestroyImmediate(webView);
webView = CreateInstance<WebViewHook>();
webView.Hook(window);
webView.LoadURL(url);
GUIUtility.keyboardControl = 0;
webView.SetApplicationFocus(true);
}
} else
{
refresh = true;
}
Basically, the idea is to recreate the webView when you dock the Editor Window. It's not very nice, but works.
Wow, thanks @studiostart ! Unfortunately Unity removed WebView from 2020, so now I'm not sure it's reasonable to use it.
Oh, you're right! They removed the webview (and so, also the Asset Store tab) from Unity. What a pity!!!