需求就是:Unity编辑器脚本工具,用于扫描项目中所有图片资源,并找出引用这些图片的预制体及其引用路径,最终导出为CSV报告。
一、在Unity的Editor目录下,新建一个名为FindTextureReferencesInPrefabs的C#脚本,Copy以下代码到你新建的名为FindStringsInScripts的C#脚本中去,最后一定要保存文件哈。
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;public static class FindTextureReferencesInPrefabs
{[MenuItem("Tools/分析图片在预制体中的引用")]public static void ScanTextureReferences(){try{// 获取所有图片资源string[] allTextures = AssetDatabase.FindAssets("t:Texture2D");Dictionary<string, List<ReferenceInfo>> textureReferences = new Dictio