Example #1
0
        private AssetBundleStatus LoadAssetBundle(string bundleName, AssetBundleWarehouse defaultWarehouse, out AssetBundleLoading operation,
                                                  out string nameWithVariant, out AssetBundleWarehouse preferedWarehouse)
        {
            preferedWarehouse = FindWarehouse(bundleName, defaultWarehouse);
            nameWithVariant   = preferedWarehouse.RemapBundleName(bundleName);

            if (_loadedAssetBundles.ContainsKey(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Loaded);
            }

            if (_loadingAssetBundleNames.Contains(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Loading);
            }

            if (_failedAssetBundleNames.Contains(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Failed);
            }
            _logger.InfoFormat("LoadAssetBundle :{0}", nameWithVariant);

            _loadingAssetBundleNames.Add(nameWithVariant);

            operation = preferedWarehouse.LoadAssetBundle(nameWithVariant);
            _loadingAssetBundles.AddLast(operation);

            return(AssetBundleStatus.Blank);
        }
Example #2
0
        private AssetBundleStatus LoadAssetBundle(string bundleName, AssetBundleWarehouse defaultWarehouse,
                                                  out AssetBundleLoading operation,
                                                  out string nameWithVariant, out AssetBundleWarehouse preferedWarehouse)
        {
            if (string.IsNullOrEmpty(bundleName))
            {
                operation         = null;
                preferedWarehouse = null;
                nameWithVariant   = bundleName;
                return(AssetBundleStatus.Failed);
            }
            preferedWarehouse = FindWarehouse(bundleName, defaultWarehouse);
            nameWithVariant   = preferedWarehouse.RemapBundleName(bundleName);

            if (string.IsNullOrEmpty(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Failed);
            }
            if (_loadedAssetBundles.ContainsKey(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Loaded);
            }

            if (_loadingAssetBundleNames.Contains(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Loading);
            }

            if (_failedAssetBundleNames.Contains(nameWithVariant))
            {
                operation = null;
                return(AssetBundleStatus.Failed);
            }

            _logger.DebugFormat("LoadAssetBundle :{0}", nameWithVariant);

            _loadingAssetBundleNames.Add(nameWithVariant);
            operation = null;
            try
            {
                operation = preferedWarehouse.LoadAssetBundle(nameWithVariant);
                _loadingAssetBundles.AddLast(operation);
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("{0}", e);
                _loadingAssetBundleNames.Remove(nameWithVariant);
                _failedAssetBundleNames.Add(nameWithVariant);
                return(AssetBundleStatus.Failed);
            }


            return(AssetBundleStatus.Blank);
        }