AssetBundleGraph.FileUtility.EnsureAssetBundleCacheDirExists C# (CSharp) Method

EnsureAssetBundleCacheDirExists() public static method

public static EnsureAssetBundleCacheDirExists ( BuildTarget t, NodeData node, bool remake = false ) : string
t BuildTarget
node NodeData
remake bool
return string
        public static string EnsureAssetBundleCacheDirExists(BuildTarget t, NodeData node, bool remake = false)
        {
            var cacheDir = FileUtility.PathCombine(AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, node.Id, BuildTargetUtility.TargetToAssetBundlePlatformName(t));

            if (!Directory.Exists(cacheDir)) {
                Directory.CreateDirectory(cacheDir);
            } else {
                if(remake) {
                    RemakeDirectory(cacheDir);
                }
            }
            return cacheDir;
        }

Usage Example

        public void Setup(BuildTarget target,
                          NodeData node,
                          ConnectionPointData inputPoint,
                          ConnectionData connectionToOutput,
                          Dictionary <string, List <Asset> > inputGroupAssets,
                          List <string> alreadyCached,
                          Action <ConnectionData, Dictionary <string, List <Asset> >, List <string> > Output)
        {
            var outputDict = new Dictionary <string, List <Asset> >();

            outputDict[key] = new List <Asset>();

            var bundleNames = inputGroupAssets.Keys.ToList();

            var bundleVariants = new Dictionary <string, List <string> >();

            // get all variant name for bundles
            foreach (var name in bundleNames)
            {
                bundleVariants[name] = new List <string>();
                var assets = inputGroupAssets[name];
                foreach (var a in assets)
                {
                    var variantName = a.variantName;
                    if (!bundleVariants[name].Contains(variantName))
                    {
                        bundleVariants[name].Add(variantName);
                    }
                }
            }

            // add manifest file
            var manifestName = BuildTargetUtility.TargetToAssetBundlePlatformName(target);

            bundleNames.Add(manifestName);
            bundleVariants[manifestName] = new List <string>()
            {
                ""
            };

            var bundleOutputDir = FileUtility.EnsureAssetBundleCacheDirExists(target, node);

            foreach (var name in bundleNames)
            {
                foreach (var v in bundleVariants[name])
                {
                    string bundleName = (string.IsNullOrEmpty(v))? name : name + "." + v;
                    Asset  bundle     = Asset.CreateAssetWithImportPath(FileUtility.PathCombine(bundleOutputDir, bundleName));
                    Asset  manifest   = Asset.CreateAssetWithImportPath(FileUtility.PathCombine(bundleOutputDir, bundleName + AssetBundleGraphSettings.MANIFEST_FOOTER));
                    outputDict[key].Add(bundle);
                    outputDict[key].Add(manifest);
                }
            }

            Output(connectionToOutput, outputDict, new List <string>());
        }
All Usage Examples Of AssetBundleGraph.FileUtility::EnsureAssetBundleCacheDirExists