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

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

打包:

①Assets下新建文件夹Editor和steamingAssets

②对选定文件打包:

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");            }        }    }}

从Asset Bundle加载预设:

1 using UnityEngine; 2 using System.Collections; 3  4 public class loadAB : MonoBehaviour { 5  6     // Use this for initialization 7     void Start () { 8         StartCoroutine (loadBundle("file://"+Application.streamingAssetsPath+"/"+"StreamingAssetsNew Prefab.assetbundle")); 9     }10     11     // Update is called once per frame12     void Update () {13     14     }15     private IEnumerator loadBundle(string path) {16         WWW load = new WWW (path);17         yield return load;18         GameObject obj = GameObject.Instantiate (load.assetBundle.mainAsset) as GameObject;19         load.assetBundle.Unload (false);20     }21 }

 

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

你可能感兴趣的文章
MySQL 数据库备份种类以及常用备份工具汇总
查看>>
mysql 数据库存储引擎怎么选择?快来看看性能测试吧
查看>>
MySQL 数据库操作指南:学习如何使用 Python 进行增删改查操作
查看>>
MySQL 数据库的高可用性分析
查看>>
MySQL 数据库设计总结
查看>>
Mysql 数据库重置ID排序
查看>>
Mysql 数据类型一日期
查看>>
MySQL 数据类型和属性
查看>>
mysql 敲错命令 想取消怎么办?
查看>>
Mysql 整形列的字节与存储范围
查看>>
mysql 断电数据损坏,无法启动
查看>>
MySQL 日期时间类型的选择
查看>>
Mysql 时间操作(当天,昨天,7天,30天,半年,全年,季度)
查看>>
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>