private static void ProcessAtlas(UIAtlas atlas, int index, AtlasUnloadType unloadType, float param_f) { if (atlas != null) { if (index < 0 || index >= atlasList.Count) { Debugger.LogError("ui atlas index is invalid->" + index); return; } AtlasData data = atlasList[index]; if (data.atlas == null) { data.atlas = atlas; } else { Debug.LogError("mulitiple load atlas->" + atlas.name); return; } ProcessAtlasUnloadType(data, unloadType, param_f); if (loadCallDic.ContainsKey(index)) { List <System.Action> list = loadCallDic[index]; if (list.Count == 0) { Debugger.LogError("load ui atlas call zero->" + atlas.name + "^" + index); RemoveAtlas(index); return; } if (data.referenceNum < 0) { data.referenceNum = 0; } data.referenceNum += (short)list.Count; System.Action callback = null; for (int i = 0, count = list.Count; i < count; i++) { callback = list[i]; if (callback != null) { callback(); } } list.Clear(); } else { RemoveAtlas(index); Debugger.LogError("load ui atlas call not contains->" + atlas.name); } } else { } }
private static void ProcessAtlasUnloadType(AtlasData atlasData, AtlasUnloadType unloadType, float param_f) { if (atlasData == null) { return; } int curu = (int)(atlasData.unloadType); int newu = (int)unloadType; if (curu >= newu) { return; } atlasData.unloadType = unloadType; if (unloadType == AtlasUnloadType.TIME) { atlasData.beginTime = Time.realtimeSinceStartup; if (param_f > atlasData.intervalTime) { atlasData.intervalTime = param_f; } } }
public void SetAtlasUnloadType(int t) { atlasUnloadType = (AtlasUnloadType)t; }
private static void RequestAtlas(short index, System.Action callback, AtlasUnloadType unloadType, float param_f) { if (index < 0 || index >= atlasList.Count) { Debugger.LogError("request atlas is invalid->" + index); return; } AtlasData data = atlasList[index]; if (data.atlas != null) { if (data.referenceNum < 0) { data.referenceNum = 0; } data.referenceNum++; ProcessAtlasUnloadType(data, unloadType, param_f); if (callback != null) { callback(); } return; } if (index < 0) { return; } if (!atlasIndexToName.ContainsKey(index)) { return; } string name = atlasIndexToName[index]; string destName; string path; int size; bool encrypt; Example.VersionFile.Type fileType; ResUpdate.GetLoadDetails(name, out destName, out path, out size, out encrypt, out fileType); if (path == null || path == "") { Debugger.LogError("ui atlas is null->" + name); return; } if (!loadCallDic.ContainsKey(index)) { loadCallDic.Add(index, new List <System.Action>()); } List <System.Action> list = loadCallDic[index]; list.Add(callback); UnloadData ulData = unloadList[index]; if (ulData.count >= 0) { ulData.count = -1; } if (list.Count == 1) { ResLoader.LoadByPath(name, destName, path, fileType, size, (asset, param) => { if (param == null) { return; } GameObject go = (GameObject)asset; Object.DontDestroyOnLoad(go); UIAtlas a = go.GetComponent <UIAtlas>(); if (a == null) { Debugger.LogError("ui atlas is invalid->" + name); } ProcessAtlas(a, index, unloadType, param_f); }, index); } }