Tools(四)——FileU3DBuild
来源:互联网 发布:淘宝离开时自动回复 编辑:程序博客网 时间:2024/06/17 19:08
目录为:Assets/Scripts/Tools/Editor,FileU3DBuild.cs这文件其实也只是单个文件打包成assetbundle而已.
using UnityEngine;using UnityEditor;using System.IO;public class FileU3dBuild { //只能选择文件,不能选择文件夹 [@MenuItem("BoLong/Build AssetBundles/From Files")] static void ExportAssetBundles(){ //相对于项目文件夹的目录 //例如:Assets/Scripts/TestScript.cs string path = AssetDatabase.GetAssetPath(Selection.activeObject); //path1:Assets/Scripts string path1 = Path.GetDirectoryName(path); BuildAssetBundleOptions option = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets;//资源包编译选项 if(path1.Length != 0) { path1 = path1.Replace("Assets/",""); string [] fileEntries1 = Directory.GetFiles(Application.dataPath + "/" +path1); foreach(string fileName in fileEntries1) { //排除meta文件 if (fileName.IndexOf(".meta") == -1) { string filePath = fileName.Replace("\\","/"); int index = filePath.LastIndexOf("/"); // /TestScript.cs filePath = filePath.Substring(index); string localPath = "Assets/" + path1; if(index > 0 ) { //文件相对于项目文件夹的目录 localPath += filePath; } Object t = AssetDatabase.LoadMainAssetAtPath(localPath); if(t != null) { string bundlePath = "Assets/" + path1 + "/" + t.name + ".unity3d"; //这在5.x里好像已经不能用了 BuildPipeline.BuildAssetBundle(t,null,bundlePath,option); } } } } else { Debug.LogError("path null"); } }}
阅读全文
0 0
- Tools(四)——FileU3DBuild
- Tools(一)——BuildMethod
- Tools(二)——BytesAdd
- Tools(三)——CollsionDetection
- Tools——PVRTrace
- Java 字节码操控框架ASM(四):Tools
- Tools——Snapdragon Profiler
- Jquery Tools介绍—Tooltips
- WebIDE—Firefox Developer Tools
- jquery tools 系列(三)——scrollable(1)
- jquery tools 系列(三)——scrollable(2)
- GP学习(二)—Executing tools and Accesubg licensing0
- Controller Tools——场景类型介绍
- ArcToolbox使用之一——Analysis Tools
- 软件安装——安装Vmware Tools
- java——gis 开发 Geo Tools
- Tools——Mali Graphics Debugger
- EXCEL图表工具箱—JWalk Chart Tools
- Vue UI组件 开发框架 服务端 辅助工具 应用实例 Demo示例
- c++之命名空间和结构体
- MyEclipse安装教程
- 命令行启动windows系统服务
- 16个java代码性能优化及android代码优化技巧
- Tools(四)——FileU3DBuild
- Activity State Changes
- 深入理解Java虚拟机——JVM性能优化
- CF
- Web worker耗尽原因定位
- Peaceful Commission HDU
- rest风格api实践初探
- 条款02:尽量以const,enum,inline替换#define
- 3分钟通过一个App的演示深入理解区块链运行原理