描述

调用 OnDestroy 以关闭 EditorWindow 窗口。


A simple example of OnDestroy()

// OnDestroy example.
// Close the window when the Button is pressed.  The window
// will receive an OnDestroy() call.

using UnityEngine; using UnityEditor;

public class OnDestroyExample : EditorWindow { [MenuItem("Examples/OnDestroyExample")] static void Init() { GetWindow<OnDestroyExample>("OnDestroy"); }

void OnGUI() { if (GUILayout.Button("Close")) { this.Close(); } }

void OnDestroy() { Debug.Log("Destroyed..."); } }