Unity Editor编辑器扩展创建窗口

代码示例

using UnityEngine;

using UnityEditor;

public class MyEditor : EditorWindow

{

 

    [MenuItem ("GameObject/window")]//入口

    static void AddWindow ()//静态函数

{      

//创建窗口

Rect  wr = new Rect (0,0,500,500);

        MyEditor window = (MyEditor)EditorWindow.GetWindowWithRect (typeof (MyEditor),wr,true,"widow name");

        window.Show();//展示OnGUI中的界面显示

  // TestWindow test = GetWindow();

    }

 

private void OnGUI() {

EditorGUILayout.BeginVertical();

GUILayout.Label("This is a test window!"); \

EditorGUILayout.EndHorizontal();

}

}

 

你可能感兴趣的:(Unity编辑器)