Example #1
0
        public static SingleBundleLoader GetLoader(string bundleName)
        {
            SingleBundleLoader loader = null;

            s_NameToLoader.TryGetValue(bundleName, out loader);
            return(loader);
        }
Example #2
0
        public static SingleBundleLoader GetLoader(int resourceIndex)
        {
            SingleBundleLoader loader = null;

            s_ResIndexToLoader.TryGetValue(resourceIndex, out loader);
            return(loader);
        }
Example #3
0
        protected override void OnRecycle()
        {
            if (m_BundleIndex != -1)
            {
                SingleBundleLoader.UnLoad(m_BundleIndex);
            }

            foreach (var dependIndex in m_DependBundleIndexList)
            {
                SingleBundleLoader.UnLoad(dependIndex);
            }
            ResetData();
        }
Example #4
0
        public static void InitBundleManifest()
        {
            if (s_ManifestBundleIndex != -1)
            {
                SingleBundleLoader.UnLoad(s_ManifestBundleIndex);
                s_ManifestBundleIndex = -1;
                s_ManifestAsset       = null;
            }

            s_ManifestBundleIndex = SingleBundleLoader.LoadSync(s_ManifestBundleName, null);
            var loader = SingleBundleLoader.GetLoader(s_ManifestBundleIndex);
            var bundle = loader.GetAssetBundle();

            s_ManifestAsset = bundle.LoadAsset <AssetBundleManifest>(s_ManifestAssetName);
        }
Example #5
0
        protected override IEnumerator LoadFuncEnumerator()
        {
            if (m_LoadState != LoadState.WaitLoad)
            {
                yield break;
            }
            m_LoadState = LoadState.Loading;
            if (s_ManifestAsset)
            {
                var depends = s_ManifestAsset.GetAllDependencies(m_BundleName);
                foreach (var depend in depends)
                {
                    var resIndex = SingleBundleLoader.LoadAsync(depend, null);
                    m_DependBundleIndexList.Add(resIndex);
                }
            }

            SingleBundleLoader bundleLoader;

            foreach (var resIndex in m_DependBundleIndexList)
            {
                bundleLoader = SingleBundleLoader.GetLoader(resIndex);
                while (!bundleLoader.IsComplate)
                {
                    yield return(null);
                }
            }

            m_BundleIndex = SingleBundleLoader.LoadAsync(m_BundleName, null);
            bundleLoader  = SingleBundleLoader.GetLoader(m_BundleIndex);
            while (!bundleLoader.IsComplate)
            {
                yield return(null);
            }

            m_Bundle    = bundleLoader.GetAssetBundle();
            m_LoadState = LoadState.Complete;

            foreach (var action in m_LoadedCallbackDict)
            {
                var callback = action.Value;
                callback(m_Bundle != null, m_Bundle);
            }

            m_LoadedCallbackDict.Clear();

            TryUnLoadByName(m_BundleName);
        }
Example #6
0
        private int InternalLoadSync(Action <bool, AssetBundle> loadedAction)
        {
            if (loadedAction == null)
            {
                loadedAction = s_DefaultLoadedCallback;
            }

            var index = ResourceManager.GetNewResourceIndex();

            m_ResouceIndexSet.Add(index);
            if (m_LoadState == LoadState.Init || m_LoadState == LoadState.WaitLoad)
            {
                var depends = s_ManifestAsset.GetAllDependencies(m_BundleName);
                foreach (var depend in depends)
                {
                    var resIndex = SingleBundleLoader.LoadSync(depend, null);
                    m_DependBundleIndexList.Add(resIndex);
                }

                m_BundleIndex = SingleBundleLoader.LoadSync(m_BundleName, null);
                var bundleLoader = SingleBundleLoader.GetLoader(m_BundleIndex);
                m_Bundle = bundleLoader.GetAssetBundle();

                m_LoadState = LoadState.Complete;
                loadedAction(m_Bundle != null, m_Bundle);
            }
            else if (m_LoadState == LoadState.Loading)
            {
                Debug.LogWarning("错误加载 fullbundleloader");
            }
            else
            {
                loadedAction(m_Bundle != null, m_Bundle);
            }

            return(index);
        }