码迷,mamicode.com
首页 > 其他好文 > 详细

AssetBundle之批量打包

时间:2015-04-23 17:13:52      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

1.2批量打包方法

using UnityEngine;
using UnityEditor;
using System.Collections;

public class ExportAssetSerielize : MonoBehaviour 
{
[MenuItem("Custom Editor/Create AssetBundles Main")]
static void CreateAssetBundleMain() 
{
//获取在project视图中选择的所有游戏对象
Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

//遍历所有的游戏对象
foreach(Object obj in SelectedAsset)
{
string sourcePath = AssetDatabase.GetAssetPath(obj);
string targetPath = Application.dataPath + @"/Prb/" + obj.name + ".assetbundle";

if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies))
{
Debug.Log(obj.name + "资源打包成功");
}
else 
{
Debug.Log(obj.name + "资源打包失败");
}
}
AssetDatabase.Refresh();// 刷新编辑器
}
}

AssetBundle之批量打包

标签:

原文地址:http://www.cnblogs.com/xwwFrank/p/4450895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!