//Clear public void Clear() { foreach (KeyValuePair <string, AssetBundle> item in this.m_mapRes) { item.Value.Unload(false); } this.m_mapRes.Clear(); this.m_AbRequest = null; }
//Clear public void Clear() { foreach( KeyValuePair<string,AssetBundle> item in this.m_mapRes ) { item.Value.Unload(false); } this.m_mapRes.Clear(); this.m_AbRequest = null; }
private Dictionary <string, AssetBundle> m_mapRes = new Dictionary <string, AssetBundle>(); //the resource map //create request public static AbRequest Create(FINISH_CALLBACK finish_callback = null, ERROR_CALLBACK error_callback = null) { GameObject go = new GameObject("AbRequest"); AbRequest req = go.AddComponent <AbRequest>(); req.m_delFinishCallback = finish_callback; req.m_delErrorCallback = error_callback; req.m_iLoadIndex = 0; req.m_iCompleteNum = 0; req.m_lstPath.Clear(); req.m_lstLoader.Clear(); req.m_mapRes.Clear(); return(req); }
//request public void Request(List<string> paths ,FINISH_CALLBACK finish_callback = null , ERROR_CALLBACK error_callback = null) { this.m_FinishCallback = finish_callback; this.m_ErrorCallback = error_callback; this.m_AbRequest = AbRequest.Create(RequestFinishCallback); for(int i = 0 ; i < paths.Count ; i++) { string path = paths[i]; if(!this.m_mapRes.ContainKey(path)) { this.m_mapRes.Add(path,null); this.m_AbRequest.Request(path); } } }
//request public void Request(List <string> paths, FINISH_CALLBACK finish_callback = null, ERROR_CALLBACK error_callback = null) { this.m_FinishCallback = finish_callback; this.m_ErrorCallback = error_callback; this.m_AbRequest = AbRequest.Create(RequestFinishCallback); for (int i = 0; i < paths.Count; i++) { string path = paths[i]; if (!this.m_mapRes.ContainKey(path)) { this.m_mapRes.Add(path, null); this.m_AbRequest.Request(path); } } }
// Use this for initialization void Start () { this.req = AbRequest.Create(finish_callback , error_callback); string path = "file:///"+Application.dataPath + "/example/bundle/item.unity3d"; this.paths.Add(path); req.Request(path); path = "file:///"+Application.dataPath + "/example/bundle/Terrain.unity3d"; this.paths.Add(path); req.Request(path); path = "file:///"+Application.dataPath + "/example/bundle/Button.unity3d"; this.paths.Add(path); req.Request(path); }