Unity中AB资源打包简单的脚本

Posted 91-jiaoteacher

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity中AB资源打包简单的脚本相关的知识,希望对你有一定的参考价值。

脚本应该放在Editor文件夹下

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

public class BuildAssetBundle {


    [MenuItem("BuildAB/BuildABToWin64/LZMA(体积小,加载慢)")]
    private static void BuildABsToWin64_LZMA()
    {
        //在assets下设定一个文件价用于存储ab资源
        string path = Application.dataPath + "/AssetBundle";
        //打包ab资源
        BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
        Debug.Log("AssetBundle资源打包完成");
    }


    [MenuItem("BuildAB/BuildABToWin64/不压缩(体积大,加载快)")]
    private static void BuildABsToWin64_UnComper()
    {
        //在assets下设定一个文件价用于存储ab资源
        string path = Application.dataPath + "/AssetBundle";
        //打包ab资源
        BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
        Debug.Log("AssetBundle资源打包完成");
    }

    [MenuItem("BuildAB/BuildABToWin64/LZ4(体积中,加载中)")]
    private static void BuildABsToWin64_LZ4()
    {
        //在assets下设定一个文件价用于存储ab资源
        string path = Application.dataPath + "/AssetBundle";
        //打包ab资源
        BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows64);
        Debug.Log("AssetBundle资源打包完成");
    }



}

 

以上是关于Unity中AB资源打包简单的脚本的主要内容,如果未能解决你的问题,请参考以下文章

unity打包-1.Asset Bundle资源打包

unity打包-1.Asset Bundle资源打包

AssetBundle Browser 教程丨Unity自带的一款AB包打包工具

AssetBundle Browser 教程丨Unity自带的一款AB包打包工具

AssetBundle Browser 教程丨Unity自带的一款AB包打包工具

Unity 项目AB资源 重复内容排查