内容简介:手机上可以把一段时间的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块钱请我喝一杯咖啡的话,请用手机扫描二维码即可通过支付宝直接向我捐款哦。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 巨头们的AI研究院战事
- 清华人工智能研究院成立「知识智能研究中心」,发布四大知识平台
- AWS在上海成立人工智能研究院
- 微软亚洲研究院:NLP将迎来黄金十年
- 微软亚洲研究院27篇论文入选AAAI 2019
- UGUI研究院之新手引导事件上下分离(二十七)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。