この方のツイートを見てやってみました。
UnityのEditor拡張で艦これタブとか誰か作ってそう
— 月琴かりん@開発修羅場 (@karinharp) October 9, 2014
Unity4.5
表示される。けど操作できない。
あ...これ満員だからクリックしても反応ないだけ?艦これやったこと無いのでわかりません\(^o^)/
using UnityEngine;
using UnityEditor;
public class Kancolle : EditorWindow
{
WebView webview;
[MenuItem("Window/Kancolle")]
static void Open ()
{
var window = GetWindow<Kancolle> ();
window.wantsMouseMove = true;
}
void OnGUI ()
{
if (webview == null) {
webview = CreateInstance<WebView> ();
webview.InitWebView ((int)position.width, (int)position.height - 23, true);
webview.LoadURL ("http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/");
} else {
webview.DoGUI (new Rect (0, 0, position.width, position.height));
}
}
}
Unity5.0
FlashPlayerに対応していません!
using UnityEngine;
using UnityEditor;
using System.Reflection;
public class Kancolle : EditorWindow
{
static BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
ScriptableObject webview;
static MethodInfo setSizeAndPosition;
[MenuItem("Window/Kancolle")]
static void Open ()
{
var window = GetWindow<Kancolle> ();
window.wantsMouseMove = true;
if (window.webview == null) {
var dockArea = typeof(EditorWindow).GetField ("m_Parent", fullBinding).GetValue (window);
var webViewType = Types.GetType ("UnityEditor.WebView", "UnityEditor.dll");
var initWebView = webViewType.GetMethod ("InitWebView", fullBinding);
var loadURL = webViewType.GetMethod ("LoadURL", fullBinding);
setSizeAndPosition = webViewType.GetMethod ("SetSizeAndPosition", fullBinding);
window.webview = CreateInstance (webViewType);
initWebView.Invoke (window.webview, new object[] {
dockArea,
0,
23,
(int)window.position.width,
(int)window.position.height - 23,
true
});
loadURL.Invoke (window.webview, new object[]{"http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/"});
}
}
void OnGUI ()
{
if(setSizeAndPosition !=null)
setSizeAndPosition.Invoke(webview,new object[]{0,
23,
(int)position.width,
(int)position.height}
);
}
}
Unity5.1.0f2
Flash動いた!
using UnityEngine;
using UnityEditor;
using System.Reflection;
public class KancolleWindow : ScriptableObject
{
static BindingFlags Flags = BindingFlags.Public | BindingFlags.Static;
[MenuItem("Window/Kancolle")]
static void Open ()
{
var type = Types.GetType ("UnityEditor.Web.WebViewEditorWindow", "UnityEditor.dll");
var methodInfo = type.GetMethod ("Create", Flags);
methodInfo = methodInfo.MakeGenericMethod (typeof(KancolleWindow));
methodInfo.Invoke (null, new object[]{
"Kancolle",
"http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/",
200, 530, 800, 600
});
}
}
Unity5.4.0
WebViewEditorWindow
が abstract になるので修正が必要です。
WebViewEditorWindowTabs
を呼び出すようにします。
using UnityEngine;
using UnityEditor;
using System.Reflection;
public class KancolleWindow : ScriptableObject
{
static BindingFlags Flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
[MenuItem ("Window/Kancolle")]
static void Open ()
{
var type = Types.GetType ("UnityEditor.Web.WebViewEditorWindowTabs", "UnityEditor.dll");
var methodInfo = type.GetMethod ("Create", Flags);
methodInfo = methodInfo.MakeGenericMethod (type);
methodInfo.Invoke (null, new object[] {
"Kancolle",
"http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/",
200, 530, 800, 600
});
}
}