public void Refresh(bool rebuildDependencies) { if (rebuildDependencies) { dependencyData = null; } if (dependencyData == null) { dependencyData = new AssetDependencyData(); } assetInfoMap = new Dictionary <string, AssetInfo>(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); idCount = 1; try { assetInfoMap.Add(string.Empty, new AssetInfo(this, string.Empty, AssetInfo.Type.BundlePath, new string[] { }, false)); CreateBundleInfos(); CreateAssetInfos(); rootTreeItem = new AssetTreeItemData(this, null, assetInfoMap[string.Empty], 0); foreach (var a in assetInfoMap.Values) { a.PostProcess(this); } rootTreeItem.PostProcess(this); AssetTreeItemData unrefs = new AssetTreeItemData(this, rootTreeItem, new AssetInfo(this, "Unreferenced", AssetInfo.Type.None, new string[] { }, false), 0); rootTreeItem.children.Add(unrefs); Dictionary <string, AssetTreeItemData> assetTypes = new Dictionary <string, AssetTreeItemData>(); foreach (var a in assetInfoMap.Values) { if (a.references.Count == 0 && a.type == AssetInfo.Type.Asset) { string typeName = AssetDatabase.GetMainAssetTypeAtPath(a.assetName).Name; //var importer = AssetImporter.GetAtPath(a.assetName); AssetTreeItemData p; if (!assetTypes.TryGetValue(typeName, out p)) { p = new AssetTreeItemData(this, unrefs, new AssetInfo(this, typeName, AssetInfo.Type.None, new string[] { }, false), 0); unrefs.children.Add(p); assetTypes.Add(typeName, p); } p.children.Add(new AssetTreeItemData(this, p, a, 0)); } } isValid = true; } catch (Exception e) { Debug.LogException(e); } }
public List <string> CreateReferenceList() { List <string> refs = new List <string>(); refs.Add(assetInfo.assetName); AssetTreeItemData p = parent; while (p != null && p.assetInfo.assetName.Length > 0 && (p.assetInfo.type == AssetInfo.Type.Bundle || p.assetInfo.type == AssetInfo.Type.Asset)) { refs.Insert(0, p.assetInfo.assetName); p = p.parent; } return(refs); }
public AssetTreeItemData(AssetBundleData abd, AssetTreeItemData p, AssetInfo i, int depth) { parent = p; assetBundleData = abd; id = idCount++; assetInfo = i; if (depth > 7) { return; } foreach (var d in assetInfo.dependencies) { if (abd.assetInfoMap.ContainsKey(d)) { //Debug.Log("Unable to find asset " + d); children.Add(new AssetTreeItemData(abd, this, abd.assetInfoMap[d], depth + 1)); abd.assetInfoMap[d].references.Add(CreateReferenceList()); } } }