マウスの位置にパレットを表示したい
Unity PROなら以下の作業で可能でした
手順
1.C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0のなかにある"System.Windows.Forms.dll"ファイルを
Assets/Pluginsの中に放り込む
2.以下のコードでマウスの位置を取得する
int x = System.Windows.Forms.Cursor.Position.X;
int y = System.Windows.Forms.Cursor.Position.Y;
おそらく、WindowsAPIを利用してますので、
Windows限定でないかと思います。
Macの方はわかりません
これと、ショートカットを組み合わせると、
マウスの位置にwindowを出現する事が可能になります。
PRO限定ですが orz
サンプル
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Collections;
public class ttCustomTools : EditorWindow
{
[MenuItem("TERA Tools/ ttCustomTools %t")]
public static void Open()
{
ttCustomTools window = EditorWindow.GetWindow();
//Windows System
int x = System.Windows.Forms.Cursor.Position.X;
int y = System.Windows.Forms.Cursor.Position.Y;
window.position = new Rect( x - 100, y - 20, 250, 50);
window.Show();
}
void OnGUI()
{
//ボタンと他のスクリプトの起動
if( GUILayout.Button ("Create SimplePlane") )
{
Debug.Log("CreateSimplePlane");
CreateSimplePlane sp = new CreateSimplePlane();
sp.Create();
Debug.Log("CreateSimplePlane Finish");
}
if( GUILayout.Button("Create Particle") ){
Debug.Log ("Create Particle system");
CreateShurikenParticle sp = new CreateShurikenParticle();
sp.Create();
}
}
参考
how to enable System.Windows.Forms for drag and drop functionality with outside applications■余談
開発の話か、開発ツールの開発の話かわかりにくいw
開発しにくいですw
0 件のコメント:
コメントを投稿