45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using Studio.Manage;
|
|
|
|
public class ResourcesFileSizeExporter
|
|
{
|
|
[MenuItem("Tools/Export Resources File Sizes to JSON")]
|
|
public static void ExportFileSizes()
|
|
{
|
|
string resourcesPath = Application.dataPath + "/Resources";
|
|
var sampleAssetPaths = Application.dataPath + "/Resources/Sample";
|
|
var fileSizeListWrapper = new FileSizeListWrapper();
|
|
if (!Directory.Exists(sampleAssetPaths))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Dictionary<string, long> fileSizes = new Dictionary<string, long>();
|
|
|
|
string[] files = Directory.GetFiles(sampleAssetPaths, "*.prefab", SearchOption.AllDirectories);
|
|
foreach (string filePath in files)
|
|
{
|
|
var fileEntry = new FileSizeEntry();
|
|
|
|
long fileByteSize = new FileInfo(filePath).Length;
|
|
string fileName = Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
fileEntry.name = fileName;
|
|
fileEntry.size = fileByteSize;
|
|
|
|
fileSizeListWrapper.files.Add(fileEntry);
|
|
}
|
|
|
|
string json = JsonConvert.SerializeObject(fileSizeListWrapper);
|
|
|
|
string outputPath = Path.Combine(resourcesPath, "FileSizes.json");
|
|
File.WriteAllText(outputPath, json);
|
|
|
|
Debug.Log($"파일 이름/크기 정보가 저장되었습니다: {outputPath}");
|
|
AssetDatabase.Refresh();
|
|
}
|
|
} |