unity Editor 下Assetbundle 打包

本文介绍了如何在Unity编辑器下进行Assetbundle的打包操作。首先清理缓存,然后获取并遍历Project视图中所有选择的游戏对象,为每个游戏对象创建AssetBundle,并将其保存到StreamingAssets目录。代码中包含了针对不同平台(UNITY_ANDROID, UNITY_IPHONE, UNITY_STANDALONE_WIN, UNITY_EDITOR)的条件编译指令。" 72844583,6871565,Qt结合libvlc实现RTSP视频播放与上层绘图,"['Qt开发', '流媒体播放', '视频处理', 'libvlc', '图形界面']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using UnityEngine;
using System.Collections;

using UnityEditor;
using System.IO;

public class CreateAssetBundle : MonoBehaviour
{
[MenuItem(“Custom/Create Object to It’s Single Bundle”)]
static void ExecuteSingleObjectCreateAssetBundle()
{
//清除缓存
Caching.CleanCache();
//获取Project视图中选择的所有游戏对象
Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
//生成AssetBundle保存目录
if (!Directory.Exists(Application.dataPath + “/StreamingAssets”))
{
Directory.CreateDirectory(Application.dataPath + “/StreamingAssets”);
}
//遍历所有游戏对象
foreach(Object _object in SelectedAsset)
{
string sourcePath = Application.dataPath + “/StreamingAssets/” + _object.name + “.assetbundle”;

        #if UNITY_ANDROID
        if(BuildPipeline.BuildAssetBundle(_object, null, sourcePath, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))
        {
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值