private void _GetAssetDependencies(Guid id, out List <U3DAssetInfo> assets) { U3DAssetInfo assetInfo = null; assets = new List <U3DAssetInfo>(); if (!U3DAssetDB.GetInstance().Find(id, out assetInfo)) { return; } string[] depPaths = ResourceManageToolUtility.GetDependencies(assetInfo.path); foreach (var p in depPaths) { if (p.Equals(assetInfo.Path)) { continue; } U3DAssetInfo depAsset = null; Guid depId = ResourceManageToolUtility.PathToGuid(p); //在数据库中没有找到此资源则初始化 if (!U3DAssetDB.GetInstance().Find(depId, out depAsset)) { depAsset = new U3DAssetInfo(); depAsset.guid = depId; ResourceManageToolUtility.InitAssetInfo(p, ref depAsset); U3DAssetDB.GetInstance().AssetTable.Add(depAsset.guid, depAsset); } assets.Add(depAsset); } assets.Sort(new AssetInfoComparer(AssetFilterList)); }
private void _UpdateAssetTableStep() { string path = iter.Current as string; if (_IsIgnoreAsset(path)) { return; } U3DAssetInfo assetInfo = new U3DAssetInfo(); ResourceManageToolUtility.InitAssetInfo(path, ref assetInfo); Guid guid = assetInfo.guid; string[] deps = ResourceManageToolUtility.GetDependencies(path); foreach (var depPath in deps) { Guid depGuid = ResourceManageToolUtility.PathToGuid(depPath); if (depGuid.Equals(guid)) { continue; } assetInfo.deps.Add(depGuid); } resultObj.assetTable.Add(guid, assetInfo); }
public bool Rebuild(Guid taskID, U3DAssetDBRebuildTask.Result res) { if (!taskID.Equals(rebuildTaskID)) { return(false); } assetTable = res.assetTable; assetReferencedTable = res.assetReferencedTable; unUsedAssets = res.unUsedAssets; rebuildTaskID = Guid.Empty; //更新数据库时间 dbUpdateTime = DateTime.Now.ToLocalTime().ToString(); //标记已经破损的资源 foreach (var corruptedId in corruptedAssets) { U3DAssetInfo info = null; if (assetTable.TryGetValue(corruptedId, out info)) { ResourceManageToolUtility.MarkAssetCorrupted(ref info); } } corruptedAssets.Clear(); Save(); return(true); }
public static void InitAssetInfo(string path, ref U3DAssetInfo assetInfo) { assetInfo.path = path; assetInfo.typeName = GetAssetTypeName(path); assetInfo.guid = new Guid(AssetDatabase.AssetPathToGUID(path)); InitAssetInfoIcon(ref assetInfo); }
public bool Check(U3DAssetInfo assetInfo) { if (Path.GetFileName(assetInfo.path).ToLower(). Contains(SearchText)) { return(true); } return(false); }
public virtual bool Check(U3DAssetInfo assetInfo) { foreach (var t in TypeNames) { if (assetInfo.TypeName.Equals(t)) { return(true); } } return(false); }
public void Init() { Clear(); string[] assetPaths = ResourceManageToolUtility.GetAllAssetPaths(); foreach (var p in assetPaths) { if (IsPathContain(p)) { U3DAssetInfo newInfo = new U3DAssetInfo(); ResourceManageToolUtility.InitAssetInfo(p, ref newInfo); assetTable.Add(newInfo.guid, newInfo); } } }
private bool _ApplySerializeObject(U3DAssetDBSerializeObject obj) { string projPath = EditorHelper.GetProjectPath(); dbUpdateTime = obj.StrUpdateTime; assetTable.Clear(); foreach (var asset in obj.AssetTable) { Guid id = new Guid(asset.Key); U3DAssetInfo info = asset.Value; string absPath = projPath + info.path; //数据库中所述路径所对应文件已经不存在 if ( !Directory.Exists(absPath) && !File.Exists(absPath) ) { Debug.LogError("Asset数据库已过期!路径\"" + info.path + "\"不存在!"); return(false); } ResourceManageToolUtility.InitAssetInfoIcon(ref info); assetTable.Add(id, info); } assetReferencedTable.Clear(); foreach (var pair in obj.AssetReferencedTable) { Guid id = new Guid(pair.Key); List <Guid> referencedList = new List <Guid>(); foreach (var referencedID in pair.Value) { Guid refId = new Guid(referencedID); referencedList.Add(refId); } assetReferencedTable.Add(id, referencedList); } unUsedAssets.Clear(); foreach (var unUsedAsset in obj.UnUsedAssets) { Guid id = new Guid(unUsedAsset); unUsedAssets.Add(id); } return(true); }
public static void InitAssetInfoIcon(ref U3DAssetInfo assetInfo) { if (assetInfo.TypeName.Equals("Texture")) { assetInfo.icon = AssetPreview.GetMiniTypeThumbnail(typeof(Texture)); } else if (assetInfo.TypeName.Equals("CubeMap")) { assetInfo.icon = AssetPreview.GetMiniTypeThumbnail(typeof(Cubemap)); } else if (assetInfo.typeName.Equals("RenderTexture")) { assetInfo.icon = AssetPreview.GetMiniTypeThumbnail(typeof(RenderTexture)); } else { assetInfo.icon = GetCachedIcon(assetInfo.path); } }
//查找某个资源被谁引用 public void GetAssetReferenced(Guid resID, out List <U3DAssetInfo> assets) { List <Guid> referencedList = null; U3DAssetDB.GetInstance().FindReferencedList(resID, out referencedList); assets = new List <U3DAssetInfo>(); if (referencedList != null) { foreach (var r in referencedList) { U3DAssetInfo info = null; if (U3DAssetDB.GetInstance().Find(r, out info)) { assets.Add(info); } } } assets.Sort(new AssetInfoComparer(AssetFilterList)); }
public List <U3DAssetInfo> GetUnUsedAssets() { List <U3DAssetInfo> list = new List <U3DAssetInfo>(); foreach (var id in unUsedAssets) { U3DAssetInfo info = null; Find(id, out info); if ( info.typeName.Equals("Scene") || info.typeName.Equals("Folder") ) { continue; } list.Add(info); } return(list); }
public string[] GetUnUsedAssetsPath() { List <string> unUsedPathList = new List <string>(); Dictionary <string, List <U3DAssetInfo> > unUsedGroupedAssets = new Dictionary <string, List <U3DAssetInfo> >(); foreach (var p in unUsedAssets) { U3DAssetInfo info = null; Find(p, out info); if (!unUsedGroupedAssets.ContainsKey(info.typeName)) { List <U3DAssetInfo> assets = new List <U3DAssetInfo>(); unUsedGroupedAssets.Add(info.typeName, assets); } List <U3DAssetInfo> assetList = null; unUsedGroupedAssets.TryGetValue(info.typeName, out assetList); assetList.Add(info); } foreach (var t in unUsedGroupedAssets) { if (t.Key.Equals("Scene")) { continue; } List <U3DAssetInfo> assets = t.Value; foreach (var a in assets) { unUsedPathList.Add(a.path); } } return(unUsedPathList.ToArray()); }
public void GetAssetDependencies(Guid resID, out List <U3DAssetInfo> assets) { assets = new List <U3DAssetInfo>(); U3DAssetInfo assetInfo = null; if (U3DAssetDB.GetInstance().Find(resID, out assetInfo)) {//若找到了查依赖的资源 //若资源已经损坏则不再构建正向依赖 if (assetInfo.Corrupted) { return; } if (assetInfo.deps.Count > 0) {//已初始化正向依赖信息 foreach (var depId in assetInfo.deps) { U3DAssetInfo depAsset = null; if (U3DAssetDB.GetInstance().Find(depId, out depAsset)) {//正向依赖资源已经收集到资源数据库中 assets.Add(depAsset); } else {//未收集到资源数据库中,建临时信息 depAsset = new U3DAssetInfo(); depAsset.guid = depId; ResourceManageToolUtility.InitAssetInfo(ResourceManageToolUtility.GuidToPath(depId), ref depAsset); assets.Add(depAsset); } } assets.Sort(new AssetInfoComparer(AssetFilterList)); } else {//未初始化正向依赖信息 _GetAssetDependencies(resID, out assets); } } }
public bool Find(Guid guid, out U3DAssetInfo info) { return(assetTable.TryGetValue(guid, out info)); }
//根据路径查找 public bool Find(string path, out U3DAssetInfo info) { Guid guid = ResourceManageToolUtility.PathToGuid(path); return(Find(guid, out info)); }
public bool Find(string path, out U3DAssetInfo info) { return(U3DAssetDB.GetInstance().Find(path, out info)); }
public override bool Check(U3DAssetInfo assetInfo) { return(true); }
public static void MarkAssetCorrupted(ref U3DAssetInfo assetInfo) { assetInfo.Corrupted = true; assetInfo.TypeName = "Corrupted"; assetInfo.icon = UnityInternalIconCache.GetInstance().GetCacheIcon("d_console.erroricon.sml"); }
static void AddAssetToResourceTreeView(U3DAssetInfo assetInfo) { TreeViewCtrl resTreeList = s_root.FindControl("_ResTreeList") as TreeViewCtrl; if (resTreeList == null) { return; } bool expandTreeNode = false; if ((ResourceManageToolModel.GetInstance().CurrFilter as NullTypeFilter) == null) {//非过滤器为全部文件则节点都展开 expandTreeNode = true; } string assetPath = assetInfo.path; string currPath = assetPath; List <TreeViewNode> currLevelNodeList = resTreeList.Roots; TreeViewNode parentNode = null; int len = 0; while (currPath != "") { int i = currPath.IndexOf('/'); if (i < 0) { i = currPath.Length; } len += i + 1; string pathNodeName = currPath.Substring(0, i); string currNodeFullPath = assetPath.Substring(0, len - 1); if (i + 1 < currPath.Length) { currPath = currPath.Substring(i + 1); } else { currPath = ""; } bool findNode = false; foreach (var treeNode in currLevelNodeList) { if (treeNode.name == pathNodeName) { findNode = true; parentNode = treeNode; currLevelNodeList = treeNode.children; break; } } if (!findNode) { U3DAssetInfo info = null; TreeViewNode newNode = new TreeViewNode(); newNode.name = pathNodeName; ResourceManageToolModel.GetInstance().Find(currNodeFullPath, out info); newNode.image = info.icon; newNode.userObject = info.guid; newNode.state.IsExpand = expandTreeNode; if (parentNode == null) {//说明需要作为根节点插入树视图中 currLevelNodeList.Add(newNode); } else { parentNode.Add(newNode); } parentNode = newNode; currLevelNodeList = newNode.children; } } }