Modify the AB package extension in batches

The script is as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class 批量化转换AB名 : MonoBehaviour
{


    [MenuItem("AB包工具/修改指定文件夹扩展名")]
    public static void SelectTexture()
    {
        string suffix = "";//后缀
        Object[] asset = Selection.GetFiltered<Object>(SelectionMode.DeepAssets);
        for (int i = 0; i < asset.Length; i++)
        {
            if (asset[i].GetType() != typeof(DefaultAsset))
            {
                AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(asset[i]));
                ai.assetBundleName = asset[i].name.ToLower() + suffix; //更改文件夹中的资源AB名称
                ai.assetBundleVariant = "assetbundle";
            }
        }
        AssetDatabase.Refresh();
    }
    [MenuItem("AB包工具/清除指定文件夹扩展名")]
    public static void SelectClear()
    {
        Object[] selectedAsset = Selection.GetFiltered<Object>(SelectionMode.DeepAssets);
        for (int i = 0; i < selectedAsset.Length; i++)
        {
            AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(selectedAsset[i]));
            ai.assetBundleName = string.Empty; //清空文件夹中的资源AB名称
            //ai.assetBundleVariant = string.Empty;

        }
        AssetDatabase.RemoveUnusedAssetBundleNames();
        AssetDatabase.Refresh();
    }

}

Realize the effect:

 Press and hold the folder to modify/clear the ab package extension in batches

Summary: Not as good as AssetBundles-Browser-master

Guess you like

Origin blog.csdn.net/Tel17610887670/article/details/127994335