public AssetInfo <T> GetAssetCache <T>(string sPath, IAssetLoader loader) where T : UnityEngine.Object { sPath = sPath.ToLower(); Cache cache = m_AssetCache.GetCache(sPath); if (cache == null) { if (loader is ABAssetLoader) { cache = new ABAssetInfo <T>(sPath, m_AssetCache); } else { cache = new AssetInfo <T>(sPath, m_AssetCache); } } m_AssetCache.AddCacheToDic(sPath, cache); AssetInfo <T> assetInfo = cache as AssetInfo <T>; if (assetInfo != null) { assetInfo.AddRef(); return(assetInfo); } else { return(null); } }
/// <summary> /// 一个资源改变了,会导致引用它的资源也改变,但是希望限制影响等级 /// </summary> /// <param name="parentInfo"></param> /// <param name="prefabType">影响等级</param> private static void TransToParent(ABAssetInfo parentInfo, EnumAB prefabType) { queue.Clear(); m_handleFiles.Clear(); queue.Enqueue(parentInfo); //m_handleFiles 这个是用来破除 资源之间引用循环关系的 while (queue.Count != 0) { var assetInfo = queue.Dequeue(); if (assetInfo.m_cacheData.bundleType >= prefabType) { assetInfo.m_hasChildrenUpdate = true; var buildinfo = GetUpdateABBuild(assetInfo.m_cacheData.bundleType, assetInfo.m_cacheData.bundleId.sceneName); AddAsset(buildinfo, assetInfo.m_cacheData); m_handleFiles.Add(assetInfo.AssetPath); foreach (var parent in assetInfo.m_parent) { if (!m_handleFiles.Contains(parent.AssetPath)) { queue.Enqueue(parent); } } } } }
public void AddParent(ABAssetInfo parent) { if (!m_parent.Contains(parent)) { m_parent.Add(parent); } if (!parent.m_children.Contains(this)) { parent.m_children.Add(this); } }
public void AddChild(ABAssetInfo child) { if (!m_children.Contains(child)) { m_children.Add(child); } if (!child.m_parent.Contains(this)) { child.m_parent.Add(this); } }
private static ABAssetInfo ColloectDependecies(string prefabPath, string fileName = "") { prefabPath = prefabPath.ToLower(); string[] depends = AssetDatabase.GetDependencies(prefabPath, false); //场景比较特殊是因为场景ab不能包含其他的资源,场景自己一个ab,所以得把场景引用的资源挪到scenemodle_ab中去 if (prefabPath.EndsWith(".unity")) { if (fileName.Contains(".")) { fileName = fileName.Substring(0, fileName.IndexOf(".")); } m_curretBundleID = new BundleID(m_currentCache.firstVersion, EnumAB.scene_ab, fileName); if (!m_abbuildDic.ContainsKey(m_curretBundleID)) { ABBundleInfo buildInfo = new ABBundleInfo(); buildInfo.bundleId = m_curretBundleID; buildInfo.firstVersion = m_currentCache.firstVersion; m_abbuildDic.Add(m_curretBundleID, buildInfo); } } ABAssetInfo parentAssetInfo = null; if (!m_dependsDic.ContainsKey(prefabPath)) { parentAssetInfo = LoadAssetData(prefabPath); m_dependsDic.Add(prefabPath, parentAssetInfo); if (depends != null) { for (int i = 0; i < depends.Length; i++) { depends[i] = depends[i].ToLower().Replace("\\", "/"); if (!depends[i].EndsWith("dll") && !depends[i].EndsWith("cs") && !depends[i].EndsWith("js")) { //场景比较特殊是因为场景ab不能包含其他的资源,场景自己一个ab,所以得把场景引用的资源挪到scenemodle_ab中去 if (prefabPath.EndsWith(".unity")) { m_curretBundleID = new BundleID(m_currentCache.firstVersion, EnumAB.scenemodle_ab); } var childAssetInfo = ColloectDependecies(depends[i]); parentAssetInfo.AddChild(childAssetInfo); } } } } else { parentAssetInfo = m_dependsDic[prefabPath]; } return(parentAssetInfo); }
/// <summary> /// 只改引用自己 这儿用到的主要是uiatlas /// </summary> /// <param name="parentInfo"></param> /// <param name="prefabType"></param> private static void TransToSelf(ABAssetInfo parentInfo, EnumAB prefabType) { Queue <ABAssetInfo> queue = new Queue <ABAssetInfo>(); queue.Enqueue(parentInfo); var buildinfo = GetUpdateABBuild(prefabType); while (queue.Count != 0) { var assetInfo = queue.Dequeue(); if (assetInfo.m_cacheData.bundleType == prefabType) { AddAsset(buildinfo, assetInfo.m_cacheData); foreach (var parent in assetInfo.m_parent) { queue.Enqueue(parent); } } } }
private static ABAssetInfo ColloectDependecies_Report(string prefabPath, string fileName = "") { prefabPath = prefabPath.ToLower(); string[] depends = AssetDatabase.GetDependencies(prefabPath, false); if (prefabPath.EndsWith(".unity")) { if (fileName.Contains(".")) { fileName = fileName.Substring(0, fileName.IndexOf(".")); } } ABAssetInfo parentAssetInfo = null; if (!m_dependsDic.ContainsKey(prefabPath)) { parentAssetInfo = X2AssetsBundleEditor.LoadAssetData(prefabPath); m_dependsDic.Add(prefabPath, parentAssetInfo); if (depends != null) { for (int i = 0; i < depends.Length; i++) { depends[i] = depends[i].ToLower().Replace("\\", "/"); if (!depends[i].EndsWith("dll") && !depends[i].EndsWith("cs") && !depends[i].EndsWith("js")) { var childAssetInfo = ColloectDependecies_Report(depends[i]); parentAssetInfo.AddChild(childAssetInfo); } } } } else { parentAssetInfo = m_dependsDic[prefabPath]; } return(parentAssetInfo); }
public void RemoveParent(ABAssetInfo parent) { m_parent.Remove(parent); parent.m_children.Remove(this); }
public void RemoveChild(ABAssetInfo child) { m_children.Remove(child); child.m_parent.Remove(this); }
public int LoadAssetAsync <T>(string sPath, ResourceMgr.AssetLoadCompleted OnAssetLoadCompleted) where T : UnityEngine.Object { ABAssetInfo <T> abAssetInfo = AssetCacheMgr.Instance.GetAssetCache <T>(sPath, this) as ABAssetInfo <T>; return(abAssetInfo.LoadAsync(this, OnAssetLoadCompleted)); }
public T LoadAsset <T>(string sPath) where T : UnityEngine.Object { ABAssetInfo <T> abAssetInfo = AssetCacheMgr.Instance.GetAssetCache <T>(sPath, this) as ABAssetInfo <T>; return(abAssetInfo.Load(this)); }