Unity3D 调用模态对话框/Unity3D MessageBox
Unity模态对话框/Unity MessageBox
很多时候,我们需要将Unity的exe产品发布到某一个平台。比如某某斗地主发布到某Q游戏。
这时候如果需要调试肿么办。办法无外乎那几个。
1:源码调试,前提是整套系统全都是你们家公司的。
2:附加进程,对启动运行的游戏,在monodevelop中进行附加进程调试,如果不是毕现的,这也是很蛋疼。
3:日志,unity的日志功能很渣渣,稍不注意就会出现日志内容字符混乱,神龙见首不见尾,漫漫日志中找内
容,无比蛋疼,最坑爹的是不一定在最后崩溃时刻能成功记录讯息。
4:本次重点啊:MessageBox,爽快的模态对话框,这个东西就可以达到,仅在异常的时候出现模态对话框,

锁定程序进程,其他时候程序随便跑啦。。。下面开始了:
怎么用呢,MessageBox存在于System.Windows.Forms.dll中,这个东西请各位看官别漏了啊。
把它放到Unity工程Assets/Plugins/下这时候程序就自动添加引用的。
接下来就是把unity的PlayerSettings中 Api Compatibility Level改为NET2.0。
这样子,侬才能在程序using了。
在使用【using System.Windows.Forms.MessageBox】后某些地方会提示类冲突。比如Application类;
这时候可以使用【using MsgBoxBase = System.Windows.Forms.MessageBox】替代,笔者就是这么凑合用的呢;

介个时候就可以使用MessageBox鸟。下面看看他给我们提供了什么呢?
==============================================================
namespace System.Windows.Forms
{
public class MessageBox
{
public static DialogResult Show(string text);
public static DialogResult Show(IWin32Window owner, string text);
public static DialogResult Show(string text, string caption);
public static DialogResult Show(IWin32Window owner, string text, string caption);
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons);
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons);
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
public static DialogResult Show(IWin32Window owner, string text, string
caption, MessageBoxButtons buttons, MessageBoxIcon icon);
public static DialogResult Show(string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton
defaultButton);
public static DialogResult Show(IWin32Window
owner, string text, string caption, MessageBoxButtons buttons,
MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);
public static DialogResult Show(string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton
defaultButton, MessageBoxOptions options);
public static
DialogResult Show(IWin32Window owner, string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton
defaultButton, MessageBoxOptions options);
}
}
==============================================================
这样子 ,你就可以
if(5<6){
MsgBoxBase.Show("Unity启禀大人,帖子又成功传播知识鸟!", this.GetType().Name, WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Error);
}

就这样,就可以在程序中只针对异常错误跳出模态对话框,你不关闭,程序也就老老实实的等着你呢。
MessageBoxButtons 枚举参考:
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.messageboxbuttons%28v=vs.110%29.aspx
MessageBoxIcon 枚举参考:
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.messageboxicon.aspx
Unity3D 调用模态对话框/Unity3D MessageBox的更多相关文章
- PreTranslateMessage中有调用模态对话框的解决方法
原文:https://blog.csdn.net/guoguojune/article/details/45332511 dlg.DoModal()截住了界面消息,所以返回时原来的pMsg的内容已经更 ...
- Bootstrap 模态对话框只加载一次 remote 数据的解决办法 转载
http://my.oschina.net/qczhang/blog/190215 摘要 前端框架 Bootstrap 的模态对话框,可以使用 remote 选项指定一个 URL,这样对话框在第一次弹 ...
- Unity3d调用iOS陀螺仪
How to write gyroscope controller with Unity3d http://blog.heyworks.com/how-to-write-gyroscope-contr ...
- QDialog 模态对话框与事件循环(exec其实就是调用了show和eventLoop.exec)
起源 qtcn中文论坛中有网友问到: 假设程序正常运行时,只有一个简单的窗体A,此时只有一个GUI主线程,在这个主线程中有一个事件循环处理窗体上的事件.当此程序运行到某阶段时,弹出一个模态窗体B(书上 ...
- QT之两种模态对话框的调用
模态对话框:就是没有关闭它之前,不能再与同一个应用程序的其他窗口进行交互. 1.show调用 LoginDialog *dlg = new LoginDialog(); dlg->setModa ...
- Unity3D调用android方法(非插件方式)
关于Unity3Dproject与androidproject的转换与合并,请參考我的另外一篇博客.假设你对Unity3Dproject增加到androidproject的过程不熟悉.也请先看完以下这 ...
- [原] unity3d调用android版 人人sdk
开发过程 遇到天坑:纯android工程没问题,集成到unity3d中 就老提示 没登陆 .最后跟到底 发现是Util.java 中 openUrl 函数出的bug.unity3d 中调android ...
- Unity3D 调用Android与IOS的剪贴板
Unity3D剪贴板 最近遇到一个需要调用Android与IOS设备本身剪贴板的需求,就是在Unity中,要将文本复制到设备本身的剪贴板中,然后在其他应用程序中都能粘贴. 最开始在网上查到的方式是使用 ...
- Qt按ESC关闭模态对话框不触发closeEvent()问题解析(ESC默认调用的是reject()函数,所以必须覆盖这个函数才会有效果)good
事情是这样的:今天调试窗体,突然发现按ESC键居然跳过closeEvent()关闭了对话框!我的关闭判断都在closeEvent()里,这直接导致非正常关闭了正在进行的工作.先重建下场景: 调用处: ...
随机推荐
- jenkins插件开发-此路是我开
一:前置环境 1. JDK1.6+ 2. maven已安装 3. jenkins已搭建 4. eclipse已安装(并安装了maven插件) 以上环境可以百度搜索并安装 我的环境是WIN7 64位系统 ...
- word2013 blog test
测试一:style里的内容能保存吗?: int read; byte * buf; int tries; int read; byte * buf ...
- Hibernate的关联映射——单向1-1关联
Hibernate的关联映射--单向1-1关联 对于单向的1-1关联关系,需要在持久化类里增加代表关联实体的成员变量,并为该成员变量添加setter方法和getter方法.从持久化类的代码上看,单向1 ...
- [问题2014S04] 复旦高等代数II(13级)每周一题(第四教学周)
[问题2014S04] 设 \(A\in M_n(\mathbb{C})\) 为可对角化的 \(n\) 阶复方阵, \(f(x)\in\mathbb{C}[x]\) 为复系数多项式, 证明: \[B ...
- shell学习笔记1
知识点1.修改输出的颜色 echo -e "\e[1;31m This is red text \e[0m" 其中,\e[1;31m 表示将输出显示为红色: \e[0m 标识将颜色 ...
- osg渲染数据高程文件
使用gdal解析DEM文件,将高程数据转换为HeightField对象,然后在osg渲染. 1 源代码 #include <gdal_priv.h> #include <osgVie ...
- js中的fadeIn()
一.fadeIn()淡入,fadeOut()淡出 fadeIn()和fadeOut()括号里边跟执行的时间
- 被table单元格colspan属性折磨了
基础知识不牢固,被colspan折磨了很长时间 table里面的td使用colspan前提条件是所跨的单元格宽度必须一样,不然显示效果会是属性不起作用或直接导致表格变形,下面的例子可以看出效果 < ...
- JQuery text()、html() 以及 val()
获得内容 - text().html() 以及 val() 三个简单实用的用于 DOM 操作的 jQuery 方法: text() - 设置或返回所选元素的文本内容 html() - 设置或返回所选元 ...
- Oracle创建定时器
--创建日志信息表(测试表) create table T_LOG( id number, datetime DATE); --插入测试数据insert into t_log values (1,'2 ...