private void ProcessOneExclude(OneInfo info) { if (null == info || info.bundleExclude) { return; } Debug.Log("exclude " + info.res); info.bundleExclude = true; if (null != info.refBy) { foreach (var refResPath in info.refBy) { if (totals.ContainsKey(refResPath)) { OneInfo refRes = totals[refResPath]; if (!refRes.bundleExclude && refRes.Type == InfoType.RES)//对于依赖它的值只处理基础资源 { ResInfo aRes = refRes as ResInfo; if (aRes.IsShaderVariants()) { continue; } ProcessOneExclude(aRes); } } } } }
private void ProcessOneSpriteAtlas(ResInfo resInfo) { List <OneInfo> deps = resInfo.depends; foreach (var dep in deps) { if (dep.Type != InfoType.RES) { continue; } ResInfo oneRes = dep as ResInfo; if (oneRes.IsTexture()) { oneRes.bundleExclude = true; List <string> refBy = oneRes.refBy; if (null != refBy) { foreach (var oneRefStr in refBy) { if (totals.ContainsKey(oneRefStr)) { OneInfo refInfo = totals[oneRefStr]; if (refInfo.Type == InfoType.RES && ((ResInfo)refInfo).IsTexture()) { continue; } refInfo.RemoveDepend(oneRes); refInfo.AddDepend(resInfo);//依赖于spriteAtlas resInfo.RefBy(refInfo.res); } } } } } }
private void OutputInfo() { string output = exportPath + "/output.txt"; Debug.Log($"start output info to {output}"); EditorUtility.DisplayProgressBar("Output Info", "writing info", 0); var totalList = totals.ToList(); totalList.Sort((pair1, pair2) => { OneInfo info1 = pair1.Value; OneInfo info2 = pair2.Value; if (info1.Type != info2.Type) { int comp = ((int)info1.Type).CompareTo((int)info2.Type); return(-comp); } return(info1.refCount.CompareTo(info2.refCount)); }); StreamWriter sw = File.CreateText(output); sw.WriteLine("res include count : {0}", resList.Count); sw.WriteLine("prefab include count : {0}", prefabList.Count); sw.WriteLine("scene include count : {0}", sceneList.Count); sw.WriteLine(); sw.WriteLine("全部资源===============>"); sw.WriteLine("count:{0}", totalList.Count); List <OneInfo> shaderInfos = new List <OneInfo>(); sw.WriteLine("===非Shader==============>"); foreach (var dpair in totalList) { OneInfo oneInfo = dpair.Value; if (oneInfo.Type == InfoType.RES && ((ResInfo)oneInfo).IsShaderPart()) { shaderInfos.Add(oneInfo); } else { sw.WriteLine(dpair.Value.ToString()); } } sw.WriteLine("===所有Shader==============>"); sw.WriteLine("shader count:{0}", shaderInfos.Count); foreach (var oneInfo in shaderInfos) { sw.WriteLine(oneInfo.ToString()); } sw.Close(); AssetDatabase.Refresh(); Debug.Log("output info done"); EditorUtility.ClearProgressBar(); }
public void RemoveDepend(OneInfo info) { if (null == depends) { return; } if (depends.Contains(info)) { depends.Remove(info); } }
public void AddDepend(OneInfo info) { if (null == depends) { depends = new List <OneInfo>(); } if (!depends.Contains(info)) { depends.Add(info); } }
private void ProcessOneInfo(OneInfo oneInfo, string[] ignorePatterns) { if (totals.ContainsKey(oneInfo.res)) { return; } totals.Add(oneInfo.res, oneInfo); if (oneInfo.NoNeedCheckDepend()) { return; } string[] deps = AssetDatabase.GetDependencies(oneInfo.res, false); if (null == deps) { return; } foreach (var dep in deps) { if (dep.Equals(oneInfo.res)) { continue; } OneInfo info = null; if (totals.ContainsKey(dep)) { info = totals[dep]; info.RefBy(oneInfo.res); oneInfo.AddDepend(info); } else if (!IsResIgnore(dep, ignorePatterns)) { bool isPrefab = dep.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase); if (isPrefab) { info = GetOrCreatePrefabInfo(dep); } else { info = GetOrCreateResInfo(dep); } info.RefBy(oneInfo.res); oneInfo.AddDepend(info); ProcessOneInfo(info, ignorePatterns); } } }
private void ProcessAllSpriteAtlas() { string _progressTitle = "处理SpriteAtlas"; EditorUtility.DisplayProgressBar(_progressTitle, "", 0); foreach (var kvp in totals) { OneInfo info = kvp.Value; if (info.Type != InfoType.RES || info.bundleExclude) { continue; } ResInfo resInfo = info as ResInfo; if (resInfo.IsSpriteAtlas()) { ProcessOneSpriteAtlas(resInfo); } } EditorUtility.ClearProgressBar(); }
private void GenBundle() { PathIdProfile.Ins.MarkUpdating(usePathId); string _progressTitle = "设置bundle"; EditorUtility.DisplayProgressBar(_progressTitle, "", 0); int index = 0; int count = totals.Count; foreach (var kvp in totals) { OneInfo resInfo = kvp.Value; if (!resInfo.bundleExclude) { resInfo.SetAssetBundleName(bundleBuild); resInfo.GenConfig(config); } index++; EditorUtility.DisplayProgressBar(_progressTitle, resInfo.res, (float)(index) / count); } EditorUtility.ClearProgressBar(); }
private void ProcessExcludeRes() { string _progressTitle = "处理bundle排除资源"; EditorUtility.DisplayProgressBar(_progressTitle, "", 0); int count = excludeRes.Count; for (int i = 0; i < count; ++i) { string exclude = excludeRes[i]; if (totals.ContainsKey(exclude)) { OneInfo oneInfo = totals[exclude]; if (!oneInfo.bundleExclude) { ProcessOneExclude(oneInfo as ResInfo); } } EditorUtility.DisplayProgressBar(_progressTitle, exclude, (float)(i + 1) / count); } EditorUtility.ClearProgressBar(); }