private void Update() { if (!ProfilerData.IsProfiling) { return; } var diff = Time.time - lastTime; if (diff <= 1f) { return; } lastTime = Time.time; #if UNITY_EDITOR //drawcall信息,只有在编辑器内有效 { drawCallCountText = string.Empty; var text = UnityEditorInternal.ProfilerDriver.GetOverviewText(UnityEditorInternal.ProfilerArea.Rendering, UnityEditorInternal.ProfilerDriver.lastFrameIndex); const string tag = "Draw Calls: "; int index = text.IndexOf(tag); if (index >= 0) { index += tag.Length; int index2 = -1; for (int i = index; i < text.Length; i++) { char ch = text[i]; if (!char.IsDigit(ch)) { index2 = i; break; } } if (index2 > index) { drawCallCountText = text.Substring(index, index2 - index); } } } #endif totalMem = ProfilerData.GetTotalMem(); unusedMem = ProfilerData.GetUnusedMem(); monoHeapMem = ProfilerData.GetMonoHeapMem(); monoUsedMem = ProfilerData.GetMonoUsedMem(); texResult = ProfilerData.GetMemByType <Texture>((a) => { return(!string.IsNullOrEmpty(a.name)); }); meshResult = ProfilerData.GetMemByType <Mesh>((a) => { return(!string.IsNullOrEmpty(a.name)); }); animClipResult = ProfilerData.GetMemByType <AnimationClip>((a) => { return(!string.IsNullOrEmpty(a.name)); }); luaNameSet.Clear(); luaResult = ProfilerData.GetMemByType <TextAsset>((a) => { var ln = a.name.ToLower(); if (luaNameSet.Contains(ln)) { return(false); } luaNameSet.Add(ln); return(ln.Contains(".lua")); }); //csvNameSet.Clear(); //csvResult = ProfilerData.GetMemByType<TextAsset>((a) => //{ // var ln = a.name.ToLower(); // if (csvNameSet.Contains(ln)) // { // return false; // } // csvNameSet.Add(ln); // return ProfilerData.IsCSV(ln); //}); luaMem = ProfilerData.GetLuaRuntimeMem(); }
void ShowLabel(string fieldName, ProfilerData.Result result) { GUI.Label(new Rect(startX, NextY(), width, height), fieldName + "数:" + result.count + " " + fieldName + "内存:" + ToMBStr(result.MB), myStyle); }