public static void Start2() { dic = new Dictionary <string, Dictionary <string, bool> >(); AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + "/" + AssetBundleManager.path, BuildAssetBundleOptions.DryRunBuild, BuildTarget.StandaloneWindows64); string[] abs = manifest.GetAllAssetBundles(); for (int i = 0; i < abs.Length; i++) { AssetBundle ab = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); string[] assets = ab.GetAllAssetNames(); for (int m = 0; m < assets.Length; m++) { if (assets[m].EndsWith(".prefab")) { Dictionary <string, bool> tmpDic = new Dictionary <string, bool>(); dic.Add(assets[m], tmpDic); string[] strs = AssetDatabase.GetDependencies(assets[m]); for (int n = 0; n < strs.Length; n++) { tmpDic.Add(strs[n], false); } } } ab.Unload(false); } string savePath = EditorUtility.SaveFilePanel("title", "", DEP_DATA_NAME, DEP_DATA_EXT); if (string.IsNullOrEmpty(savePath)) { return; } FileInfo fi = new FileInfo(savePath); if (fi.Exists) { fi.Delete(); } using (FileStream fs = fi.Create()) { using (BinaryWriter bw = new BinaryWriter(fs)) { DepRecord.ToBytes(bw, dic); } } }
public static void Start() { Object obj = Selection.activeObject; if (obj == null) { return; } string findPath = AssetDatabase.GetAssetPath(obj); Debug.Log("asset:" + findPath); if (dic == null) { string path = EditorUtility.OpenFilePanel("title", "", DEP_DATA_EXT); if (string.IsNullOrEmpty(path)) { return; } FileInfo fi = new FileInfo(path); using (FileStream fs = fi.OpenRead()) { using (BinaryReader br = new BinaryReader(fs)) { dic = DepRecord.FromBytes(br); } } } IEnumerator <KeyValuePair <string, Dictionary <string, bool> > > enumerator = dic.GetEnumerator(); while (enumerator.MoveNext()) { string key = enumerator.Current.Key; Dictionary <string, bool> tmpDic = enumerator.Current.Value; if (tmpDic.ContainsKey(findPath)) { Debug.Log("parent:" + key); } } }