以Gmail为例。
点击屏幕的Capture按钮得到当前屏幕截图,点击Send按钮将之前的截图作为附件发送邮件。

using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates; public class TryDemo : MonoBehaviour { // Use this for initialization
void Start () { } // Update is called once per frame
void Update () { } void OnGUI() {
if (GUI.Button(new Rect(, , , ), "Capture")) {
Debug.Log("Capture Screenshot");
Application.CaptureScreenshot("screen.png");
}
if (GUI.Button(new Rect(, , , ), "Send")) {
SendEmail();
}
} private void SendEmail()
{
MailMessage mail = new MailMessage(); mail.From = new MailAddress("youraddress@gmail.com");
mail.To.Add("youraddress@qq.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
mail.Attachments.Add(new Attachment("screen.png")); SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = ;
smtpServer.Credentials = new System.Net.NetworkCredential("youraddress@gmail.com", "yourpassword")as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; }; smtpServer.Send(mail);
Debug.Log("success");
}
}

①Application.RegisterLogCallback(OnDebugCallBackHandler);可以给debug的打印加入回调函数,监听每次的打印,通过这个来判断是否有出错日志并作出反应
②基本的发送错误日志方法就是通过邮件发送,可以通过在unity中用c#脚本来发送邮件,具体方法在上文有提到;也可以通过Process.Start(“name.exe”)来调用外部程序发送日志邮件,具体操作可以百度c编程发送邮件,有很多例子。
③用c#脚本发送邮件日志更方便实现,c#提供了邮件发送功能的封装。另外还可以用Application.CaptureScreenshot(“filename”)来保存截图用于发送,提供错误时程序截图。

原文链接

最新文章

  1. [转]抓取安卓APP内接口的方法--Charles
  2. 轻量级应用开发之(02)UIView
  3. 《verilog数字系统设计教程》书评
  4. POJ 3177 Redundant Paths(Tarjan)
  5. 小白日记3:kali渗透测试之被动信息收集(二)-dig、whios、dnsenum、fierce
  6. Bzoj-2820 YY的GCD Mobius反演,分块
  7. OS开发网络篇—监测网络状态
  8. C#操作Excel总结
  9. 我的Python成长之路---第三天---Python基础(12)---2016年1月16日(雾霾)
  10. 设置控件Enable=false,控件颜色不变
  11. 使用 dom4j 处理 xml (2)
  12. hadoop day 7
  13. [ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0-rc1:compile (default) on project zeus-web: Command 解决
  14. [OpenCV] Samples 18: Load image and check its attributes
  15. js - 如何使子元素阻止继承父元素事件
  16. 《MinDoc 接口文档在线管理系统》
  17. 向大家推荐一个在.Net下使用C#语言和Managed DirectX 9开发游戏的视频教程
  18. 封装一个统一返回json结果类JsonResult
  19. 0702-spring cloud config-git仓库配置、用户授权
  20. Linux网络编程案例分析

热门文章

  1. AJAX同步和异步的区别
  2. 算法模板——sap网络最大流 3(递归+邻接矩阵)
  3. java深拷贝和浅拷贝
  4. TypeScript设计模式之中介者、观察者
  5. T——SQL基础语句(定义变量,赋值,取值,分支,循环,存储过程)
  6. Apache无法启动原因
  7. js提交表单错误:document.form.submit() is not a function
  8. vs打开项目出错:未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.props”的解决办法
  9. 【一】Swift 3.0 新浪微博项目实战 -整体框架搭建
  10. iOS开发之数据存储之Core Data