Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Created October 21, 2016 12:58
Show Gist options
  • Save rraallvv/09cde641ba7a03a33bb6ce337221f968 to your computer and use it in GitHub Desktop.
Save rraallvv/09cde641ba7a03a33bb6ce337221f968 to your computer and use it in GitHub Desktop.
Using gree's unity-webview in EditorWindow
# Using gree's unity-webview in EditorWindow
# https://github.com/gree/unity-webview
using UnityEditor;
using UnityEngine;
public class WebViewEditorWindow : EditorWindow
{
static GameObject go;
static WebViewObject wvo;
[MenuItem("Window/UnityWebViewTwitter")]
static void Open()
{
var win = CreateInstance<WebViewEditorWindow>();
win.minSize = new Vector2(Screen.width, Screen.height + 32);
win.maxSize = new Vector2(Screen.width, Screen.height + 32);
go = EditorUtility.CreateGameObjectWithHideFlags("wvo", HideFlags.HideAndDontSave);
wvo = go.AddComponent<WebViewObject>();
wvo.Init(
ld: (msg) =>
{
Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
});
wvo.SetMargins(0, 0, 0, 0);
wvo.SetVisibility(true);
wvo.LoadURL("https://mobile.twitter.com");
win.Show();
}
void OnDestroy()
{
DestroyImmediate(go);
wvo = null;
go = null;
}
void OnGUI()
{
if (wvo != null)
{
wvo.OnGUI();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment