initial commit
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QO
|
||||
{
|
||||
// Token: 0x0200015F RID: 351
|
||||
[ExecuteInEditMode]
|
||||
public class AllocMem : MonoBehaviour
|
||||
{
|
||||
// Token: 0x06000A22 RID: 2594 RVA: 0x0002D02C File Offset: 0x0002B22C
|
||||
public void Start()
|
||||
{
|
||||
base.useGUILayout = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000A23 RID: 2595 RVA: 0x0002D038 File Offset: 0x0002B238
|
||||
public void OnGUI()
|
||||
{
|
||||
if (!this.show || (!Application.isPlaying && !this.showInEditor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = GC.CollectionCount(0);
|
||||
if (this.lastCollectNum != (float)num)
|
||||
{
|
||||
this.lastCollectNum = (float)num;
|
||||
this.delta = Time.realtimeSinceStartup - this.lastCollect;
|
||||
this.lastCollect = Time.realtimeSinceStartup;
|
||||
this.lastDeltaTime = Time.deltaTime;
|
||||
this.collectAlloc = this.allocMem;
|
||||
}
|
||||
this.allocMem = (int)GC.GetTotalMemory(false);
|
||||
this.peakAlloc = ((this.allocMem <= this.peakAlloc) ? this.peakAlloc : this.allocMem);
|
||||
if (Time.realtimeSinceStartup - this.lastAllocSet > 0.3f)
|
||||
{
|
||||
int num2 = this.allocMem - this.lastAllocMemory;
|
||||
this.lastAllocMemory = this.allocMem;
|
||||
this.lastAllocSet = Time.realtimeSinceStartup;
|
||||
if (num2 >= 0)
|
||||
{
|
||||
this.allocRate = num2;
|
||||
}
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("usedHeapSize ");
|
||||
stringBuilder.Append(string.Concat(new object[]
|
||||
{
|
||||
Profiler.usedHeapSize / 1024f,
|
||||
" KB / ",
|
||||
(float)SystemInfo.systemMemorySize * 1024f,
|
||||
" KB"
|
||||
}));
|
||||
stringBuilder.Append("\r\n");
|
||||
stringBuilder.Append("Currently allocated ");
|
||||
stringBuilder.Append(((float)this.allocMem / 1024f).ToString("0"));
|
||||
stringBuilder.Append("KB\r\n");
|
||||
stringBuilder.Append("Peak allocated ");
|
||||
stringBuilder.Append(((float)this.peakAlloc / 1024f).ToString("0"));
|
||||
stringBuilder.Append("KB (last collect ");
|
||||
stringBuilder.Append(((float)this.collectAlloc / 1024f).ToString("0"));
|
||||
stringBuilder.Append(" KB)\r\n");
|
||||
stringBuilder.Append("Allocation rate ");
|
||||
stringBuilder.Append(((float)this.allocRate / 1024f).ToString("0.0"));
|
||||
stringBuilder.Append("KB\r\n");
|
||||
stringBuilder.Append("Collection frequency ");
|
||||
stringBuilder.Append(this.delta.ToString("0.00"));
|
||||
stringBuilder.Append("s\r\n");
|
||||
stringBuilder.Append("Last collect delta ");
|
||||
stringBuilder.Append(this.lastDeltaTime.ToString("0.000"));
|
||||
stringBuilder.Append("s (");
|
||||
stringBuilder.Append((1f / this.lastDeltaTime).ToString("0.0"));
|
||||
stringBuilder.Append(" fps)");
|
||||
if (this.showFPS)
|
||||
{
|
||||
stringBuilder.Append("\r\n" + (1f / Time.deltaTime).ToString("0.0") + " fps");
|
||||
}
|
||||
GUI.Box(new Rect(5f, 5f, 310f, (float)(80 + ((!this.showFPS) ? 0 : 16))), string.Empty);
|
||||
GUI.Label(new Rect(10f, 5f, 2000f, 400f), stringBuilder.ToString());
|
||||
}
|
||||
|
||||
// Token: 0x0400083E RID: 2110
|
||||
public bool show = true;
|
||||
|
||||
// Token: 0x0400083F RID: 2111
|
||||
public bool showFPS;
|
||||
|
||||
// Token: 0x04000840 RID: 2112
|
||||
public bool showInEditor;
|
||||
|
||||
// Token: 0x04000841 RID: 2113
|
||||
private float lastCollect;
|
||||
|
||||
// Token: 0x04000842 RID: 2114
|
||||
private float lastCollectNum;
|
||||
|
||||
// Token: 0x04000843 RID: 2115
|
||||
private float delta;
|
||||
|
||||
// Token: 0x04000844 RID: 2116
|
||||
private float lastDeltaTime;
|
||||
|
||||
// Token: 0x04000845 RID: 2117
|
||||
private int allocRate;
|
||||
|
||||
// Token: 0x04000846 RID: 2118
|
||||
private int lastAllocMemory;
|
||||
|
||||
// Token: 0x04000847 RID: 2119
|
||||
private float lastAllocSet = -9999f;
|
||||
|
||||
// Token: 0x04000848 RID: 2120
|
||||
private int allocMem;
|
||||
|
||||
// Token: 0x04000849 RID: 2121
|
||||
private int collectAlloc;
|
||||
|
||||
// Token: 0x0400084A RID: 2122
|
||||
private int peakAlloc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace QO.IO
|
||||
{
|
||||
// Token: 0x02000173 RID: 371
|
||||
public class QODirectory
|
||||
{
|
||||
// Token: 0x06000A90 RID: 2704 RVA: 0x0002E8C0 File Offset: 0x0002CAC0
|
||||
public static List<string> CollectFile(string directory, string extension, bool isWithChild = false)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
return list;
|
||||
}
|
||||
foreach (string text in Directory.GetFiles(directory))
|
||||
{
|
||||
if (text.IndexOf(".meta") < 0)
|
||||
{
|
||||
if (text.IndexOf(extension) >= 0)
|
||||
{
|
||||
list.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isWithChild)
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(directory);
|
||||
foreach (string directory2 in directories)
|
||||
{
|
||||
foreach (string item in QODirectory.CollectFile(directory2, extension, isWithChild))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// Token: 0x06000A91 RID: 2705 RVA: 0x0002E9BC File Offset: 0x0002CBBC
|
||||
public static void CreatePathToFileDirectory(string filePath)
|
||||
{
|
||||
string text = string.Empty;
|
||||
string[] array = filePath.Split(new char[]
|
||||
{
|
||||
'/'
|
||||
});
|
||||
for (int i = 0; i < array.Length - 1; i++)
|
||||
{
|
||||
text = text + "/" + array[i];
|
||||
}
|
||||
if (text != string.Empty)
|
||||
{
|
||||
text = text.Substring(1);
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user