예제 #1
0
        private void AssetBundleLoadingHook(IAssetBundleLoadingContext context)
        {
            if (context.Parameters.LoadType != AssetBundleLoadType.LoadFromFile)
            {
                return;
            }

            var path = context.Parameters.Path;

            if (path == null)
            {
                return;
            }

            var abdataIndex = path.IndexOf("/abdata/");

            if (abdataIndex == -1)
            {
                return;
            }

            string bundle = path.Substring(abdataIndex).Replace("/abdata/", "");

            if (!File.Exists(path))
            {
                if (BundleManager.Bundles.TryGetValue(bundle, out List <LazyCustom <AssetBundle> > lazyList))
                {
                    context.Bundle      = lazyList[0].Instance;
                    context.Bundle.name = bundle;
                    context.Complete();
                }
                else
                {
                    //Create a placeholder asset bundle for png files without a matching asset bundle
                    if (IsPngFolderOnly(bundle))
                    {
                        context.Bundle      = AssetBundleHelper.CreateEmptyAssetBundle();
                        context.Bundle.name = bundle;
                        context.Complete();
                    }
                    //Placeholder for .csv excel data
                    else if (Lists.ExternalExcelData.ContainsKey(bundle))
                    {
                        context.Bundle      = AssetBundleHelper.CreateEmptyAssetBundle();
                        context.Bundle.name = bundle;
                        context.Complete();
                    }
                }
            }
            else
            {
                var ab = AssetBundle.LoadFromFile(context.Parameters.Path, context.Parameters.Crc, context.Parameters.Offset);
                if (ab != null)
                {
                    context.Bundle      = ab;
                    context.Bundle.name = bundle;
                    context.Complete();
                }
            }
        }
예제 #2
0
        private void AssetBundleLoadingHook(AssetBundleLoadingContext context)
        {
            if (!File.Exists(context.Parameters.Path))
            {
                string bundle = context.Parameters.Path.Substring(context.Parameters.Path.IndexOf("/abdata/")).Replace("/abdata/", "");

                if (BundleManager.Bundles.TryGetValue(bundle, out List <LazyCustom <AssetBundle> > lazyList))
                {
                    context.Bundle      = lazyList[0].Instance;
                    context.Bundle.name = bundle;
                    context.Complete();
                }
                else
                {
                    //Create a placeholder asset bundle for png files without a matching asset bundle
                    if (IsPngFolderOnly(bundle))
                    {
                        context.Bundle      = AssetBundleHelper.CreateEmptyAssetBundle();
                        context.Bundle.name = bundle;
                        context.Complete();
                    }
                }
            }
        }