Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Created October 21, 2016 13:06
Show Gist options
  • Select an option

  • Save rraallvv/1e99f01a33ec49a4c5b448b864f795a0 to your computer and use it in GitHub Desktop.

Select an option

Save rraallvv/1e99f01a33ec49a4c5b448b864f795a0 to your computer and use it in GitHub Desktop.
Using the built-in Unity's in-editor WebView
// Using the built-in Unity's in-editor WebView
using UnityEditor;
using UnityEngine;
using System.Reflection;
// cf. http://qiita.com/kyusyukeigo/items/a7d3940b95c4ec224d12 (in Japanese)
public class TwitterWindow : ScriptableObject
{
[MenuItem("Window/Twitter")]
static void OpenTwitter()
{
var flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
#if UNITY_5_4_OR_NEWER
var type = (typeof(Editor).Assembly).GetType("UnityEditor.Web.WebViewEditorWindowTabs");
//var type = Types.GetType("UnityEditor.Web.WebViewEditorWindowTabs", "UnityEditor.dll");
#else
var type = Types.GetType("UnityEditor.Web.WebViewEditorWindow", "UnityEditor.dll");
#endif
var methodInfo = type.GetMethod("Create", flags);
methodInfo = methodInfo.MakeGenericMethod(type);
methodInfo.Invoke(
null,
new object[]
{
"Twitter",
"https://mobile.twitter.com",
200, 500, 800, 600
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment