Files
Main/Assets/Editor/DIY/Profiler/ProfilerEditorUtils.cs
2025-01-25 04:38:09 +08:00

77 lines
1.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Thousandto.Core.Framework;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Thousandto.Profiler.Editor
{
/// <summary>
/// 打包工具的额外菜单比如fls操作在dll里面不方便定菜单挪到这里
/// </summary>
public class ProfilerEditorUtils
{
public static Texture WhiteBlank;
public static Texture BlackBlank;
static ProfilerEditorUtils()
{
InitTexBlank();
}
//标题栏内容
public static string[] TitleArray = new string[]
{
"开始加载",
"结束加载",
"加载耗时",
"使用次数",
"卸载时间",
"卸载次数",
"生存时间",
};
public static void GetProfilerInformation()
{
var info = AssetsProfiler.Information();
SaveInfo("../info.txt", info);
UnityEngine.Debug.Log(info);
}
public static void GetHistoryInformation()
{
var info = AssetsProfiler.HistoryInformation();
SaveInfo("../historyInfo.txt", info);
UnityEngine.Debug.Log(info);
}
public static void SaveInfo(string path, string info)
{
File.WriteAllText(path, info);
}
public static Texture2D CreateColorTex(Color color, int w, int h)
{
Texture2D tex = new Texture2D(w, h);
for (int i = 0; i < w; ++i)
{
for (int n = 0; n < h; ++n)
{
tex.SetPixel(i, n, color);
}
}
tex.Apply();
return tex;
}
private static void InitTexBlank()
{
WhiteBlank = CreateColorTex(new Color(1, 1, 1, 0.01f), 10, 10);
BlackBlank = CreateColorTex(new Color(0, 0, 0, 0.1f), 10, 10);
}
}
}