示例#1
0
        public AssetBundleReference LoadAssetBundleSync(string path, string tag, bool standalone = true)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            AssetBundleReference abr = null;

            if (m_AssetBundles.ContainsKey(path))
            {
                #if ASSETMANAGER_LOG
                Debug.LogFormat("LoadAssetBundleSync bundle is loaded {0},{1}", path, Time.frameCount);
                #endif
                abr = m_AssetBundles[path];
                //refresh
                abr.AddTag(tag);

                if (standalone)
                {
                    abr.Chain();
                }
            }
            else
            {
                if (m_LoadingAssetBundleLoaders.ContainsKey(path))
                {
                    Debug.LogErrorFormat("LoadAssetBundleSync async loader is active {0},{1}", path, Time.frameCount);
                    //TODO Stop async
                    return(null);
                }
                else
                {
                    #if ASSETMANAGER_LOG
                    Debug.LogFormat("LoadAssetBundleSync create new loader {0},{1}", path, Time.frameCount);
                    #endif
                    AssetBundleSyncLoader loader = m_LoaderManager.CreateAssetBundleSyncLoader(path);
                    if (loader != null)
                    {
                        loader.state = Loader.State.Inited;
                        loader.Start();
                        abr = loader.result;
                        OnAssetBundleLoaded(loader);
                    }
                }
            }

            return(abr);
        }
示例#2
0
        public AssetBundleSyncLoader CreateAssetBundleSyncLoader(string path)
        {
            AssetBundleSyncLoader loader = null;

#if !UNITY_EDITOR || ASSET_BUNDLE_LOADER
            AssetBundleInfo info = null;
            info = m_AssetManager.infoManager.FindAssetBundleInfo(path);
            if (info != null)
            {
                loader              = new AssetBundleSyncLoader();
                loader.info         = info;
                loader.assetManager = m_AssetManager;
            }
            else
            {
                Debug.LogErrorFormat("Can't find asset bundle info {0}", path);
            }
#endif

            return(loader);
        }