最简单的打包方式

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class menuitem : Editor
{
//菜单项
    [MenuItem("create/click")]
    static void A() {
//选中的多个资源
        GameObject[] games = Selection.gameObjects;
        foreach (var item in games)
        {
              //资源的路径
            string path = AssetDatabase.GetAssetPath(item);
            //通过路径获得资源
            AssetImporter ai = AssetImporter.GetAtPath(path);
           //ab包的名字
            ai.assetBundleName = "cube";
        }
        //打包逻辑
        BuildPipeline.BuildAssetBundles("Assets/AB",BuildAssetBundleOptions.None,BuildTarget.StandaloneWindows64);
    }
}

猜你喜欢

转载自blog.csdn.net/itliruochong/article/details/80317977