杂项

当前位置:首页>技术博客>杂项
全部 15 TFrame框架 2 游戏渲染 0 编辑器扩展 0 性能优化 3 SDK 4 数据结构和算法 1 杂项 5

Unity中EXE弹出Windows提示框

时间:2021-07-21   访问量:1330

参考文章:

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();
            }
        }
    }
}


上一篇:Unity发送GET和POST请求

下一篇:Android上使用AES-128/GCM + BASE64加解密

发表评论:

评论记录:

未查询到任何数据!