博客
关于我
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 - 有条件的删除重复项
查看>>
pandas -按连续日期时间段分组
查看>>
pandas -更改重新采样的时间序列的开始和结束日期
查看>>
SpringBoot+Vue+Redis前后端分离家具商城平台系统(源码+论文初稿直接运行《精品毕设》)15主要设计:用户登录、注册、商城分类、商品浏览、查看、购物车、订单、支付、以及后台的管理
查看>>
pandas :to_excel() float_format
查看>>
pandas :从数据透视表中的另一列中减去一列
查看>>
pandas :加入有条件的数据框
查看>>
pandas :将多列汇总为一列,没有最后一列
查看>>
pandas :将时间戳转换为 datetime.date
查看>>
pandas :将行取消堆叠到新列中
查看>>
pandas :设置编号.最大行数
查看>>
pandas DataFrame 中的自定义浮点格式
查看>>
Pandas DataFrame 的 describe()方法详解-ChatGPT4o作答
查看>>
Pandas DataFrame中删除列级的方法链接解决方案
查看>>
Pandas DataFrame中的列从浮点数输出到货币(负值)
查看>>
Pandas DataFrame中的列从浮点数输出到货币(负值)
查看>>
Pandas DataFrame多索引透视表-删除空头和轴行
查看>>
pandas DataFrame的一些操作
查看>>
Pandas Dataframe的日志文件
查看>>
Pandas df.iterrows() 并行化
查看>>