Created
October 21, 2016 13:06
-
-
Save rraallvv/1e99f01a33ec49a4c5b448b864f795a0 to your computer and use it in GitHub Desktop.
Using the built-in Unity's in-editor WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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