内容简介:手机上可以把一段时间的profiler日志保存在本地,接着在手机里把文件取出来就可以在电脑上查看了,很方便,上代码,在需要保存手机Profiler日志的时候调用 ProfilerUtils.BeginRecord();并且我已经封装好了。
手机上可以把一段时间的profiler日志保存在本地,接着在手机里把文件取出来就可以在电脑上查看了,很方便,上代码,在需要保存手机Profiler日志的时候调用 ProfilerUtils.BeginRecord();并且我已经封装好了。
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Profiling;
public class ProfilerUtils {
static private GameObject profilerGameObject;
static ProfilerUtils(){
profilerGameObject = new GameObject("#Profiler#");
UnityEngine.Object.DontDestroyOnLoad(profilerGameObject);
}
static public void BeginRecord()
{
if(!profilerGameObject.GetComponent<InternalBehaviour>()){
profilerGameObject.AddComponent<InternalBehaviour>();
}
}
class InternalBehaviour : MonoBehaviour
{
private string m_DebugInfo = String.Empty;
private void OnGUI()
{
GUILayout.Label(String.Format("<size=50>{0}</size>", m_DebugInfo));
}
IEnumerator Start()
{
for (int i = 5; i > 0; i--)
{
m_DebugInfo = string.Format("<color=blue>{0}s后开始保存Profiler日志</color>", i);
yield return new WaitForSeconds(1);
}
string file = Application.persistentDataPath + "/profiler_" + DateTime.Now.ToString("yyyyMMddhhmmss") +".log";
Profiler.logFile = file;
Profiler.enabled = true;
Profiler.enableBinaryLog = true;
for (int i = 5; i > 0; i--)
{
m_DebugInfo = string.Format("<color=red>{0}s后结束保存Profiler日志</color>", i);
yield return new WaitForSeconds(1);
}
Profiler.enableBinaryLog = false;
m_DebugInfo = string.Format("保存完毕:{0}", file);
yield return new WaitForSeconds(10);
Destroy(this);
}
}
}
最后在Profier窗口中点击load载入即可,如果你用的unity版本比较老,并没有load按钮,调用Proilfer.AddframesFromeFile也可以载入profiler信息。
- 本文固定链接: https://www.xuanyusong.com/archives/4551
- 转载请注明:雨松MOMO 于雨松MOMO程序研究院 发表
雨松MOMO提醒您:亲,如果您觉得本文不错,快快将这篇文章分享出去吧 。另外请点击网站顶部彩色广告或者捐赠支持本站发展,谢谢!
捐 赠 如果您愿意花20块钱请我喝一杯咖啡的话,请用手机扫描二维码即可通过支付宝直接向我捐款哦。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
深入浅出Ext JS
何启伟、徐会生、康爱媛 / 人民邮电出版社 / 2010-5 / 69.00元
以用户为中心的时代,应用的界面外观变得越来越重要。然而,很多程序员都缺乏美术功底,要开发出界面美观的应用实属不易。Ext JS的出现,为广大程序员解决了这一难题。它有丰富多彩的界面和强大的功能,是开发具有炫丽外观的RIA应用的最佳选择。 本书是《深入浅出Ext JS》的升级版,涵盖了最新发布的Ext JS 3.2新特性,并对上一版的内容进行增补,充实了示例代码,同时补充了两个功能强大的实例。......一起来看看 《深入浅出Ext JS》 这本书的介绍吧!