博客
关于我
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/

你可能感兴趣的文章
Pharmaceutical的同学们都看过来,关于补码运算的复习相关内容
查看>>
Phaser性能测试加强版
查看>>
phoenix 开发API系列(一)创建简单的http api
查看>>
Phoenix 查看表信息及修改元数据
查看>>
phoenixframework集成了所有自动化测试的思想的平台。mark一下。
查看>>
phoenix_执行sql报错_Error: ERROR 504 (42703): Undefined column. columnName=(state=4270_大数据工作笔记0181
查看>>
phoenix启动失败_The history file `/root/.sqlline/history` may be an older history---记录024_大数据工作笔记0184
查看>>
Phoenix基础命令_视图映射和表映射_数字存储问题---大数据之Hbase工作笔记0036
查看>>
phoenix无法连接hbase shell创建表失败_报错_PleaseHoldException: Master is initializing---记录020_大数据工作笔记0180
查看>>
Phoenix简介_安装部署_以及连接使用---大数据之Hbase工作笔记0035
查看>>
phoenix连接hbase报错Can not resolve hadoop120, please check your network_记录026---大数据工作笔记0187
查看>>
PhotoPrism:这款获得35.8K星的AI照片管理神器你值得拥有
查看>>
Photoshop工作笔记001---Photoshop常用快捷键总结
查看>>
photoshop智能参考线
查看>>
Reids配置文件redis.conf中文详解
查看>>
Photoshop脚本入门
查看>>
PHP
查看>>
Regular Expression Notes
查看>>
PHP $FILES error码对应错误信息
查看>>
PHP $_FILES函数详解
查看>>