//编译完的回调 //[UnityEditor.Callbacks.DidReloadScripts] private static void OnScriptsReloaded() { if (EditorApplication.isPlaying) { Debug.LogError("cannot be launched in Play mode."); return; } DestroyWindow(); window = CreateInstance <FightTest>(); //创建窗口 rect = new Rect(200, 200, 800, 800); //window = (FightTest)EditorWindow.GetWindow(typeof(FightTest)); //window.titleContent = "draw test"; window.minSize = new Vector2(800, 800); //window.maxSize = new Vector2(800, 800); window.position = rect; texture = new Texture2D(1, 1); texture.SetPixel(0, 0, Color.white); texture.Apply(); texture.hideFlags = HideFlags.DontSave; window.Show(); //window.ShowPopup(); //window.ShowUtility(); }
private static void DestroyWindow() { if (window != null) { window.Close(); DestroyImmediate(window); window = null; } }