public int CompareTo(OneResource other) { if (this.reference > other.reference) { return(1); } if (this.reference < other.reference) { return(-1); } return(0); }
static OneResource TryGetOneResource(string guid, string path, Dictionary <string, OneResource> allresources) { OneResource or = null; if (!allresources.TryGetValue(guid, out or)) { or = new OneResource(); or.guid = guid; or.path = path; allresources.Add(guid, or); } return(or); }
static void AddDepend(FileInfo file, Dictionary <string, OneResource> allresources) { string path = Frame.Helper.ConvertToPathStartWithAsset(file.FullName); string curguid = AssetDatabase.AssetPathToGUID(path); OneResource current = TryGetOneResource(curguid, path, allresources); string[] dependencies = AssetDatabase.GetDependencies(path); if (dependencies != null && dependencies.Length > 0) { foreach (var dep in dependencies) { if (!dep.EndsWith(".cs") && !dep.EndsWith(".js")) { if (current.dependices.Contains(dep)) { continue; } string guid = AssetDatabase.AssetPathToGUID(dep); OneResource dep_resource = TryGetOneResource(guid, dep, allresources); dep_resource.reference++; current.dependices.Add(dep); } } foreach (var dep in dependencies) { if (!dep.EndsWith(".cs") && !dep.EndsWith(".js")) { string guid = AssetDatabase.AssetPathToGUID(dep); if (dep.ToLower() == path.ToLower()) { continue; } FileInfo childfile = new FileInfo(dep); AddDepend(childfile, allresources); } } } }