参考文章:
https://www.cnblogs.com/chinarbolg/p/9601391.html
[DllImport("User32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] public static extern int MessageBox(IntPtr handle, String message, String title, int type);//具体方法 [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); //游戏窗口 static IntPtr _kGameHwnd = IntPtr.Zero; public static void ShowAlert(string title, string message,Action callback) { if (!UnityEngine.Application.isMobilePlatform) { _kGameHwnd = FindWindow(null, "exe程序名"); var dialogResult = MessageBox(_kGameHwnd, message, title, 0); if (dialogResult == 1) { if (callback != null) { callback(); } } } }