Unity资源热更新----AssetBundle

13.1 资源热更新——AssetBundle1-1_哔哩哔哩_bilibili

Resources 性能消耗较大

Resources文件夹大小不能超过2个G

获取AssetBundle中的资源

打包流程

选择图片后点击

创建文件夹,Editor优先编译

打包文件夹位置

using UnityEditor;
using UnityEngine;

public class SimpleBuild : Editor
{
    [MenuItem("AssetBundle/EasyBuild")]
    public static void EasyBuild() {
        BuildPipeline.BuildAssetBundles(Application.dataPath+ "/ABPackage"/*Bundle输入路径*/,
            //BuildAssetBundleOptions.None-->LZMA包小,加载慢
            BuildAssetBundleOptions.ChunkBasedCompression,/*包中等,加载快*/
            //BuildAssetBundleOptions.UncompressedAssetBundle--->不压缩,加载快
            //目标平台 ,苹果平台BuildTarget.StandaloneOSX
            BuildTarget.StandaloneWindows64
            );
    }
}

加载

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SimpleLoad : MonoBehaviour
{
    public RawImage showImg;
    private void Start()
    {
        //简单文件加载
        AssetBundle loadedPic=AssetBundle.LoadFromFile(Application.dataPath + "/ABPackage/unitypicture");
        //解包
        Texture texture = loadedPic.LoadAsset<Texture>("Unity");
        showImg.texture = texture;
    }
}

p161

上一篇:Apache Paimon 的 Query Service 使用


下一篇:通过WireShark对比IPsec VPN不同配置方式和算法下的报文封装差异