少年修仙传客户端代码仓库
client_Zxw
2018-11-13 d2dd33cc0ca421e276d50abc46688f5db83aa42b
Core/ResModule/AssetBundle/AssetBundleUtility.cs
@@ -8,6 +8,8 @@
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>>();
@@ -187,6 +189,18 @@
            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)
        {
@@ -211,6 +225,8 @@
        }
        CacheAssetBundle(assetBundleName, _request.assetBundle);
        m_LoadingAssetBundleList.Remove(assetBundleName);
    }
    private IEnumerator Co_LoadAssetBundleDependenice(AssetBundleInfo assetBundleInfo)
@@ -242,11 +258,35 @@
    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)
@@ -270,6 +310,7 @@
            }
        }
        m_LoadingAssetList.Remove(_checkTag);
    }
    private IEnumerator Co_DoLoadAsset(AssetInfo assetInfo, Action<bool, UnityEngine.Object> callBack = null)