Exemplo n.º 1
0
        //----------------------------------------------------------------------------
        public bool StartLoad <T, U>(string strAssetID, Callback <T, U> result)
        {
            if (m_state != FileSystemState.File_OK)
            {
                Debug.LogError("StartLoad m_state " + m_state.ToString() + " " + strAssetID + "! FileSystemState.File_OK");
                return(false);
            }
            if (result == null)
            {
                Debug.LogError(string.Format("{0} is not hava callback!", strAssetID));
                return(false);
            }

            sAssetInfo info = sAssetInfo.zero;

            m_ResourceList.GetAssetBundleInfo(strAssetID, ref info);
            if (string.IsNullOrEmpty(info.strFile))
            {
                Debug.LogError(strAssetID + "  Is not exist in anywhere");
                return(false);
            }

            UnityEngine.Object obj = assetsManager.GetAssetObjByID(strAssetID);
            if (obj != null)
            {
                Callback <string, object> callback = result as Callback <string, object>;
                callback(strAssetID, obj);
                return(true);
            }
            AssetBundle bundle = null;

            if (m_assetBundleDict.TryGetValue(info.strFile, out bundle))
            {
                Callback <string, UnityEngine.Object> callback = result as Callback <string, UnityEngine.Object>;
                string loadAssetName         = string.IsNullOrEmpty(info.assetName) ? info.strName : info.assetName;
                UnityEngine.Object[] objlist = bundle.LoadAllAssets();
                var count = objlist.Length;
                for (int i = 0; i < objlist.Length; i++)
                {
                    ProcessAsset(strAssetID, objlist[i], callback, info.eAssetType, count, i);
                    ProcessStreamedAsset(info, objlist[i], bundle);
                }
            }
            else
            {
                sNeedLoadData needLoad;
                needLoad.strAssetID = strAssetID;
                needLoad.callback   = result as Callback <string, UnityEngine.Object>;
                m_queueNeedLoad.Enqueue(needLoad);
                m_bHaveNeedLoad = true;
            }
            return(true);
        }