Version: 2020.3

描述

调用 OnDestroy 以关闭 EditorWindow 窗口。

\ 一个简单的 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..."); } }