Beispiel #1
0
        /// <summary> 定義されていないアセットバンドル名を削除 </summary>
        public static void DeleteUndefinedAssetBundleNames(AssetManagement assetManagement)
        {
            var assetBundleNames = assetManagement.GetAllAssetInfos()
                                   .Where(x => x.IsAssetBundle && x.AssetBundle != null)
                                   .Select(x => x.AssetBundle.AssetBundleName)
                                   .Distinct()
                                   .ToHashSet();

            var allAssetBundleNames = AssetDatabase.GetAllAssetBundleNames();

            foreach (var assetBundleName in allAssetBundleNames)
            {
                if (assetBundleNames.Contains(assetBundleName))
                {
                    continue;
                }

                AssetDatabase.RemoveAssetBundleName(assetBundleName, true);
            }
        }
Beispiel #2
0
        private static AssetInfoManifest GenerateManifest(AssetManagement assetManagement)
        {
            var projectFolders = ProjectFolders.Instance;

            var externalResourcesPath = projectFolders.ExternalResourcesPath;

            var allAssetInfos = assetManagement.GetAllAssetInfos().ToArray();

            // アセット情報を更新.
            var manifestPath = GetManifestPath(externalResourcesPath);
            var manifest     = ScriptableObjectGenerator.Generate <AssetInfoManifest>(manifestPath);

            Reflection.SetPrivateField(manifest, "assetInfos", allAssetInfos);

            UnityEditorUtility.SaveAsset(manifest);

            // アセットバンドル名設定.
            var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(manifest));

            importer.assetBundleName = AssetInfoManifest.AssetBundleName;
            importer.SaveAndReimport();

            return(manifest);
        }