Unity 打包模型的方法
来源:互联网 发布:怎么删除软件 编辑:程序博客网 时间:2024/05/16 18:14
模型导出
首先要根据不同的平台有不同的打包方法,在代码中要有平台的区分执行不同的打包代码,用到的材质类型要在GraphicsSettings中设置一下,不然特效或者模型的材质容易丢失,打包时选中Project中的预设体,点击Custom Editor就可以导出,Custom Editor在菜单栏中,这个类要放在Editor文件夹中。
using UnityEngine; using System.Collections; using UnityEditor; public class Test : Editor { [MenuItem("Custom Editor/Create AssetBunldes Main")] static void CreateAssetBunldesMain () { //获取在Project视图中选择的所有游戏对象 Object[] SelectedAsset = Selection.GetFiltered (typeof(Object), SelectionMode.DeepAssets); //遍历所有的游戏对象 foreach (Object obj in SelectedAsset) { string sourcePath = AssetDatabase.GetAssetPath (obj); //本地测试:建议最后将Assetbundle放在StreamingAssets文件夹下,如果没有就创建一个,因为移动平台下只能读取这个路径 //StreamingAssets是只读路径,不能写入 //服务器下载:就不需要放在这里,服务器上客户端用www类进行下载。 // #if UNITY_ANDROID string targetPath = "F:/" + obj.name + ".assetbundle"; #elif UNITY_IPHONE string targetPath = Application.dataPath + "/StreamingAssets/" + obj.name + ".assetbundle"; #endif bool dabao = #if UNITY_ANDROID BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); #elif UNITY_IPHONE BuildPipeline.BuildAssetBundle(obj, null, targetPath,BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iOS ); #elif UNITY_STANDALONE_WIN || UNITY_EDITOR BuildPipeline.BuildAssetBundle (obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies) #else string.Empty; #endif if (dabao) { Debug.Log(obj.name +"资源打包成功"); } else { Debug.Log(obj.name +"资源打包失败"); } } //刷新编辑器 AssetDatabase.Refresh (); } }
0 0
- Unity 打包模型的方法
- unity打包模型存在的一个问题
- unity 打包IPA,减少文件大小的方法
- 关于Unity的模型以及场景打包的代码
- unity打包IOS最好不要使用的排序方法
- unity 关于assetbundle 打包和加载的方法
- Unity最新版打包AssetBundle和加载的方法
- 关于采用Unity 5.x 提供的增量式打包单个模型后AssetBundle doesn’t have main asset解决方法
- Unity模型导入的若干问题
- Unity 模型的制作规范
- Unity支持的模型文件
- Unity 模型的制作规范
- Unity 模型的制作规范
- Unity模型导入的Check
- 【Unity】安卓项目使用带有资源Jar包SDK的打包方法
- Unity打包内部prefab和读取外部assetbundle的方法详解。
- Unity打包
- unity打包到android的图标问题
- UITableView 如何不动态计算返回的cell 的高度
- 几句代码实现轻量级可拖动button
- mysql查询成绩排名显示-两种排名方式
- android之LinearLayout
- 误写zlib带来的问题
- Unity 打包模型的方法
- MATLAB版2048
- Android 系列 3.12保持你的应用程序snappy与StrictMode
- [UIDeviceRGBColor length]: unrecognized selector sent to instance
- mac中程序死机/关闭程序方法(含terminal)
- Toolbar动态隐藏右侧按钮
- Unity 中的坐标系
- 名企笔试:腾讯2016研发工程师笔试题(赛车问题)
- mms8916 lk阶段ADC