public static Resource LoadResource(uint resId, OnLoadResource onLoad) { Resource res; if (m_resMap.TryGetValue(resId, out res)) { return(res); } else { StartDownloadResource(resId, onLoad); return(null); } }
private static void StartDownloadResource(uint resId, OnLoadResource onLoad) { OnLoadResource callBack; if (m_resOnLoadMap.TryGetValue(resId, out callBack)) { if (null != onLoad) { callBack -= onLoad; callBack += onLoad; } } else { string strUrl = GetResourceUrl(resId); if (string.IsNullOrEmpty(strUrl)) { Debug.LogError("cant find this resId's config"); return; } m_resOnLoadMap.Add(resId, onLoad); Downloader.WWWDownloadResource(resId, strUrl, OnDownloadEnd); } }