public static AssetFileInfo GetAssetFileInfo(long guid) { if (sAssetFileInfos == null) { sAssetFileInfos = new Dictionary <long, AssetFileInfo>(); } AssetFileInfo info; if (!sAssetFileInfos.TryGetValue(guid, out info)) { info = new AssetFileInfo { guid = guid }; sAssetFileInfos.Add(guid, info); } return(info); }
public static void ObjectAddToFileInfo(Object o, SerializedObject serializedObject, AssetBundleFileInfo info) { if (!o) { return; } string name2 = o.name; string type = o.GetType().ToString(); if (type.StartsWith("UnityEngine.")) { type = type.Substring(12); // 如果是内置的组件,就不当作是资源 if (o as Component) { return; } } else if (type == "UnityEditor.Animations.AnimatorController") { type = "AnimatorController"; } else if (type == "UnityEditorInternal.AnimatorController") { type = "AnimatorController"; } else if (type == "UnityEditor.MonoScript") { MonoScript ms = o as MonoScript; string type2 = ms.GetClass().ToString(); if (type2.StartsWith("UnityEngine.")) { // 内置的脚本对象也不显示出来 return; } // 外部的组件脚本,保留下来 type = "MonoScript"; } else { // 外部的组件脚本,走上面的MonoScript if (o as Component) { return; } // 外部的序列化对象,已经被脚本给分析完毕了,不需要再添加进来 if (o as ScriptableObject) { return; } Debug.LogError("What's this? " + type); return; } // 内建的资源排除掉 string assetPath = AssetDatabase.GetAssetPath(o); if (!string.IsNullOrEmpty(assetPath)) { return; } long guid; if (info.isScene) { // 场景的话,没法根据PathID来确定唯一性,那么就认为每个场景用到的资源都不一样 guid = (info.name + name2 + type).GetHashCode(); } else { SerializedProperty pathIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); #if UNITY_5 || UNITY_5_3_OR_NEWER guid = pathIdProp.longValue; #else guid = pathIdProp.intValue; #endif } if (info.IsAssetContain(guid)) { return; } AssetFileInfo info2 = AssetBundleFilesAnalyze.GetAssetFileInfo(guid); info2.name = name2; info2.type = type; info2.includedBundles.Add(info); if (info2.detailHyperLink == null) { // 初次创建对象时链接为空 info2.detailHyperLink = new OfficeOpenXml.ExcelHyperLink(System.String.Empty, info2.name); info2.propertys = AnalyzeObject(o, serializedObject, info.rootPath, info.name); } info.assets.Add(info2); }