protected virtual void BuildDataDir(int depth, AssetModel.AssetInfo dirInfo, TreeViewItem parent) { var dirItem = new AssetTreeViewItem <AssetModel.AssetInfo>(dirInfo.id, depth, dirInfo.displayName, dirInfo); parent.AddChild(dirItem); if (dirInfo.hasChildren) { foreach (var childInfo in dirInfo.children) { BuildDataDir(depth + 1, childInfo, dirItem); } } }
/// <summary> /// 去引用到的目录查找所有用到的guid,批量更改 /// </summary> private void OnContextUseThisItem(object userdata) { var item = userdata as AssetTreeViewItem <AssetModel.AssetInfo>; if (item != null) { AssetModel.AssetInfo group = ((AssetTreeViewItem <AssetModel.AssetInfo>)item.parent).data; AssetModel.AssetInfo useInfo = item.data; var style = AssetDanshariStyle.Get(); if (!EditorUtility.DisplayDialog(String.Empty, style.sureStr + style.duplicateContextOnlyUseThis.text, style.sureStr, style.cancelStr)) { return; } Dictionary <string, List <string> > beReplaceDic = new Dictionary <string, List <string> >(); for (int i = group.children.Count - 1; i >= 0; i--) { var info = group.children[i]; if (info != useInfo) { //存储依赖info的资源路径 if (info.hasChildren) { List <string> depList = new List <string>(); for (int j = 0; j < info.children.Count; j++) { depList.Add(info.children[j].fileRelativePath); } beReplaceDic.Add(info.fileRelativePath, depList); } AssetDatabase.DeleteAsset(info.fileRelativePath); info.deleted = true; } } ((AssetRepeatModel)m_Model).SetUseThis(useInfo.fileRelativePath, beReplaceDic); EditorUtility.DisplayDialog(String.Empty, style.progressFinish, style.sureStr); AssetDatabase.Refresh(); Repaint(); } }