Reprinted from:Yusong MOMO Published at Yusong MOMO Program Research Institute on February 14, 2019
Above code:
using UnityEditor;
public class Test
{
[InitializeOnLoadMethod]
static void InitializeOnLoadMethod()
{
EditorApplication.wantsToQuit -= Quit;
EditorApplication.wantsToQuit += Quit;
}
static bool Quit()
{
EditorUtility.DisplayDialog("我就是不让你关闭unity", "我就是不让你关闭unity", "呵呵");
return false; //return true表示可以关闭unity编辑器
}
}
Effect:
Isn't it interesting? Clicking "x" or alt+F4 doesn't work. You can only close the task manager or shut down the computer, haha!