Пример #1
0
        private static void ClearAssetBundleInfos(AssetBundleOrganizer organizer)
        {
            var root = organizer.AssetBundleInfoTreeRoot;

            if (!root.Children.ContainsKey(AssetBundleRoot))
            {
                return;
            }

            var genRoot = root.Children[AssetBundleRoot];
            var assetBundlesToDelete = new List <string>();

            foreach (var kv in genRoot.Children)
            {
                var assetBundleInfo = kv.Value;
                if (!assetBundleInfo.IsDirectory)
                {
                    assetBundlesToDelete.Add(assetBundleInfo.Path);
                }
            }

            foreach (var assetBundlePath in assetBundlesToDelete)
            {
                organizer.DeleteAssetBundle(assetBundlePath);
            }

            organizer.SaveConfig();
        }
Пример #2
0
        private static void GenerateAssetBundleInfos(AssetBundleOrganizer organizer)
        {
            var genAssetRoot = organizer.AssetInfoForestRoots.SingleOrDefault(root => root.Path == GeneratedAssetPath);

            foreach (var kv in genAssetRoot.Children)
            {
                var assetInfo = kv.Value;
                if (!assetInfo.IsFile || !string.IsNullOrEmpty(assetInfo.AssetBundlePath))
                {
                    continue;
                }

                var abPath = Path.Combine(AssetBundleRoot, Path.GetFileNameWithoutExtension(assetInfo.Name) ?? throw new NullReferenceException());
                organizer.CreateNewAssetBundle(abPath, Constant.CommonResourceGroupId, false);
                organizer.AssignAssetsToBundle(new[] { assetInfo }, abPath);
            }

            organizer.SaveConfig();
        }