博客
关于我
unity3d打包和包的使用
阅读量:650 次
发布时间:2019-03-15

本文共 1372 字,大约阅读时间需要 4 分钟。

AssetBundle打包指南

步骤一:在Assets文件夹中创建两个新文件夹,分别命名为Editor和streamingAssets。             步骤二:选择需要打包的文件并进行打包操作。             以下是完整的代码示例:
using UnityEngine;using UnityEditor;using System.Collections;

public class AssetBundle : MonoBehaviour{[MenuItem("Custom Editor/Create AssetBundles Main")]static void CreateAssetBundlesMain(){Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);foreach (Object obj in SelectedAsset){string sourcePath = AssetDatabase.GetAssetPath(obj);string targetPath = Application.dataPath + "/StreamingAssets" + obj.name + ".assetbundle";

if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies))        {            Debug.Log(obj.name + " success");        }        else         {            Debug.Log(obj.name + " failure");        }    }}

}

如何从AssetBundle加载预设

使用以下代码可以实现从AssetBundle中加载预设的功能: using UnityEngine;using System.Collections;public class LoadAB : MonoBehaviour {    public void Start()    {        StartCoroutine(LoadBundle("file://"+Application.streamingAssetsPath+"/"+"StreamingAssetsNew Prefab.assetbundle"));    }    private IEnumerator LoadBundle(string path)    {        WWW load = new WWW(path);        yield return load;        GameObject obj = GameObject.Instantiate(load.assetBundle.mainAsset) as GameObject;        load.assetBundle.Unload(false);    }}

转载地址:http://oxelz.baihongyu.com/

你可能感兴趣的文章
pandas 滚动窗口 - datetime64[ns] 未实现
查看>>
pandas 版本兼容特定的蟒蛇和NumPy配置吗?
查看>>
pandas 生成excel多级表头
查看>>
Pandas 的 DataFrame 详解-ChatGPT4o作答
查看>>
pandas 读取excel数据,以字典形式输出
查看>>
Pandas 读取具有浮点值的 csv 文件会导致奇怪的舍入和小数位数
查看>>
pandas 适用,但仅适用于满足条件的行
查看>>
pandas 重新采样到每月的特定工作日
查看>>
pandas :如何删除以NaN为列名的多个列?
查看>>
pandas :我如何对堆叠的条形图进行分组?
查看>>
pandas :按移位分组和累加和(GroupBy Shift And Cumulative Sum)
查看>>
pandas :检测一个DF和另一个DF之间缺失的列
查看>>
Pandas-从具有嵌套列表列表的现有列创建动态列时出错
查看>>
Pandas-通过对列和索引的值求和来合并两个数据框
查看>>
pandas.columns、get_dummies等用法
查看>>
pandas.DataFrame.copy(deep=True) 实际上并不创建深拷贝
查看>>
pandas.read_csv()的详解-ChatGPT4o作答
查看>>
PANDAS.READ_EXCEL()输出‘;溢出错误:日期值超出范围‘;而不存在日期列
查看>>
pandas100个骚操作:再见 for 循环!速度提升315倍!
查看>>
Pandas:如何根据其他列值的条件对列进行求和?
查看>>