性能优化3——脚本获取语句耗时

var beginTime = System.DateTime.UtcNow.Ticks;

............

var endTime = System.DateTime.UtcNow.Ticks;
var deltaTime = endTime - beginTime;
Debug.Log($"{deltaTime / 10000.0}ms");

中间放入语句即可,非常感谢

Unity中实现一键删除丢失的(Missing)脚本_unity 移除错误的脚本-CSDN博客

方法②:

Stopwatch sw = new Stopwatch();
sw.Start();

...............

sw.Stop();
UnityEngine.Debug.Log(string.Format("Stopwatch total: {0} ms",sw.ElapsedMilliseconds));

非常感谢:【技巧】Unity检测方法执行时间_unity testmethod-CSDN博客

posted @ 2024-02-23 17:36  terrificia  阅读(14)  评论(0编辑  收藏  举报