| | |
| | | public class AssetBundleUtility : SingletonMonobehaviour<AssetBundleUtility>
|
| | | {
|
| | | private List<AssetBundleInfo> m_AssetBundleInfoList = new List<AssetBundleInfo>();
|
| | | private List<string> m_LoadingAssetBundleList = new List<string>();
|
| | | private List<string> m_LoadingAssetList = new List<string>();
|
| | | private Dictionary<string, AssetInfo> m_AssetInfoDict = new Dictionary<string, AssetInfo>();
|
| | | private Dictionary<string, AssetBundle> m_AssetBundleDict = new Dictionary<string, AssetBundle>();
|
| | | private Dictionary<string, Dictionary<string, UnityEngine.Object>> m_AssetDict = new Dictionary<string, Dictionary<string, UnityEngine.Object>>();
|
| | |
| | | yield break;
|
| | | }
|
| | |
|
| | | if (m_LoadingAssetBundleList.Contains(assetBundleName))
|
| | | {
|
| | | while (!m_AssetBundleDict.ContainsKey(assetBundleName))
|
| | | {
|
| | | // Debug.Log(Time.frameCount + " ] 正在加载AssetBundle: " + assetBundleName + ", 请等待...");
|
| | | yield return null;
|
| | | }
|
| | | yield break;
|
| | | }
|
| | |
|
| | | m_LoadingAssetBundleList.Add(assetBundleName);
|
| | |
|
| | | var _assetBundleInfo = GetAssetBundleInfo(assetBundleName);
|
| | | if (_assetBundleInfo == null)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | CacheAssetBundle(assetBundleName, _request.assetBundle);
|
| | |
|
| | | m_LoadingAssetBundleList.Remove(assetBundleName);
|
| | | }
|
| | |
|
| | | private IEnumerator Co_LoadAssetBundleDependenice(AssetBundleInfo assetBundleInfo)
|
| | |
| | |
|
| | | private IEnumerator Co_DoLoadAsset(string assetBundleName, string assetName, Action<bool, UnityEngine.Object> callBack = null)
|
| | | {
|
| | | #if UNITY_5
|
| | | assetBundleName = assetBundleName.ToLower();
|
| | | #endif
|
| | |
|
| | | #if UNITY_EDITOR
|
| | | RunTimeABLoadLog.AddLog(assetBundleName, assetName, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
|
| | | #endif
|
| | |
|
| | | yield return Co_LoadAssetBundle(assetBundleName);
|
| | |
|
| | | string _checkTag = assetBundleName + "@" + assetName;
|
| | | if (m_LoadingAssetList.Contains(_checkTag))
|
| | | {
|
| | | while (!m_AssetDict.ContainsKey(assetBundleName)
|
| | | || !m_AssetDict[assetBundleName].ContainsKey(assetName))
|
| | | {
|
| | | // Debug.Log(Time.frameCount + " ] 正在加载Asset: " + _checkTag + ", 请等待...");
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | if (callBack != null)
|
| | | {
|
| | | callBack(true, m_AssetDict[assetBundleName][assetName]);
|
| | | }
|
| | |
|
| | | yield break;
|
| | | }
|
| | |
|
| | | m_LoadingAssetList.Add(_checkTag);
|
| | |
|
| | | var request = m_AssetBundleDict[assetBundleName].LoadAssetAsync(assetName);
|
| | | while (!request.isDone)
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | m_LoadingAssetList.Remove(_checkTag);
|
| | | }
|
| | |
|
| | | private IEnumerator Co_DoLoadAsset(AssetInfo assetInfo, Action<bool, UnityEngine.Object> callBack = null)
|