public void Update() { if (m_LoadingRes.Count > 0) { m_curResInfo = m_LoadingRes[0]; Object asset; if (m_cacheRes.TryGetValue(m_curResInfo.name, out asset)) { //do nothing; } else { asset = AssetDatabase.LoadAssetAtPath(m_curResInfo.name, m_curResInfo.type); m_cacheRes.Add(m_curResInfo.name, asset); } if (asset != null) { m_curResInfo.cb(true, asset); m_LoadingRes.Remove(m_curResInfo); } else { DebugMgr.LogError("加载资源失败:" + m_curResInfo.name); } } }
public void LoadAsset(string name, Type type, LoadAssetCallBack cb) { ResInfo resinfo = new ResInfo(name, type, cb); m_LoadingRes.Add(resinfo); }