Unity 导出Assetbundle的脚本
来源:互联网 发布:淘宝上好看的女装店铺 编辑:程序博客网 时间:2024/05/19 20:59
转自:http://blog.csdn.net/zhou_xw6511/article/details/9795493
今天查看了一下如何打包资源Assetbundle 的东西 现在粘上
/// <summary>
/// 分开打包
/// 把project 视图中包含的资源一一打包
/// </summary>
[MenuItem("Assets/Build AssetBundle From Sence One By One ")]
static void ExportResourceOnebyOne()
{
//获取在Project视图中选择的所有游戏对象
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
//遍历所有游戏对象
foreach (Object asset in selection)
{
//得到物体的路径
// string sourcePath = AssetDatabase.GetAssetPath(asset);
//本地测试:建议最后将Assetbundle放在StreamingAssets文件夹下,如果没有就创建一个,因为移动平台下只能读取这个路径
//StreamingAssets 路径下的文件只能读取 不能写入
//放在服务器上的资源没有要求
string targetPath = Application.dataPath + "/StreamingAssets/" + asset.name + ".unity3d";
if (targetPath != null)
{
if (BuildPipeline.BuildAssetBundle(asset, null, targetPath, BuildAssetBundleOptions.CollectDependencies))
{
Debug.Log("create Assetbundle Success!");
}
else
{
Debug.Log("Create Assetbundle failed!");
}
}
}
AssetDatabase.Refresh(); //刷新编辑器
}
/// <summary>
/// 打包为一个资源包
/// </summary>
[MenuItem("Assets/Build AssetBundle From Sence all object ")]
static void ExoprtResourcuAll()
{
Caching.CleanCache();
string Path = Application.dataPath + "/StreamingAssets/ALL.unity3d";
Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
foreach (Object obj in SelectedAsset)
{
Debug.Log("Create AssetBunldes name :" + obj);
}
//这里注意第二个参数就行
if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.CollectDependencies))
{
AssetDatabase.Refresh();
}
else
{
}
}
/// <summary>
/// 打包PC平台的资源包文件
/// </summary>
[MenuItem("Assets/Build AssetBundle From Selection TO BuildTarget is PC -Track dependencies")]
static void ExportResourcePcTrackdependencies()
{
//保存打包资源的
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length!=0)
{
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);
Selection.objects = selection;
}
}
/// <summary>
/// 打包PC 资源不关联相应的资源 只打包资源本省
/// </summary>
[MenuItem("Assets/Build AssetBundle From SelectionTO BuildTarget is PC -NO dependencies tracking")]
static void ExportResourcePcNodependenciesTracking()
{
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length!=0)
{
BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path);
}
}
/// <summary>
/// 把场景打包成Stream文件
///
/// 如何加载场景
/// WWW download = WWW.LoadFromCacheOrDownload("http://xxx/streamed.unity3d",0);
/// yield return download;
/// Application.LoadLevel("Level1");
///
///
/// </summary>
[MenuItem("build/BuildWebplayerStreamed")]
static void Build()
{
string[] levels = new string[] { "Sence1","Sence2","Sence3","......" };
BuildPipeline.BuildStreamedSceneAssetBundle(levels, "streamed.unity3d", BuildTarget.WebPlayer);
}
- Unity 导出Assetbundle的脚本
- Unity 到处Assetbundle的脚本
- 超级好用的Unity中的AssetBundle打包脚本,
- Unity AssetBundle的使用
- unity AssetBundle的资源管理
- Unity Assetbundle的原理
- Unity Assetbundle的实战
- unity的assetbundle加载
- Unity 5 的Assetbundle 以及unity 4的Assetbundle 食用方法
- unity AssetBundle
- unity-AssetBundle
- <Unity> AssetBundle
- Unity AssetBundle
- unity批量更改assetbundle名称、清除名称打包脚本
- unity 代码设置要打包的AssetBundle
- 你应该知道的Unity AssetBundle管理机制
- Unity的动态加载AssetBundle资源笔记。
- Unity之AssetBundle的实际应用
- Android Studio初步使用配置
- EFI接口详解
- 视频教学
- OpenTSDB-2.1.0RC1安装记录
- 前缀表达式
- Unity 导出Assetbundle的脚本
- CentOS root密码的修改。
- 基本RC积分电路及原理分析
- has leaked ServiceConnection
- 建材电商的呐喊:踢开我们脚下的绊脚石
- [Leetcode] 8. String to Integer (atoi)
- ArrayList和LinkList的对比
- Mqtt协议规范
- c++中模板使用时候typename和class的区别