Tools(二)——BytesAdd
来源:互联网 发布:福州 java 编辑:程序博客网 时间:2024/06/06 02:24
依然是Assets/Scripts/Tools/Editor目录下BytesAdd.cs这个文件的代码有错,估计没使用了,又没改吧。
using UnityEngine;using UnityEditor;using System.IO;using System.Collections;public class BytesAdd{ ////这个函数实际上需要选择一个文件夹, //这函数就是打包选中的文件夹下的所有文件(包括meta) //但是里面的path很有问题 //这函数不改了,也改不了 [@MenuItem("BoLong/Build AssetBundles/From bytes of Files")] static void ExportAssetBundles(){ //这里返回的是相对项目文件夹的路径 //例如:Assets/MyTextures/hello.png string path = AssetDatabase.GetAssetPath(Selection.activeObject); BuildAssetBundleOptions option = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets;//资源包编译选项 if(path.Length !=0 ) { path = path.Replace("Assets/",""); //获取目录下的所有文件,不递归 string [] fileEntries = Directory.GetFiles(Application.dataPath + "/" + path); foreach(string fileName in fileEntries){ string filePath = fileName; int index = filePath.LastIndexOf("/"); //这里filePath变成这样子了: // /Materials\111.mat.bytes filePath = filePath.Substring(index); int indexp = path.LastIndexOf("/"); //这里这path是外部变量,减着减着就没了,就会报错 //如果只执行一次的话,就是获取path文件夹所有在目录 path = path.Substring(0,indexp); //这又重新把 Assets/加上去,上面已经减去过了 string localPath = "Assets/" + path; if(index > 0) { localPath += filePath; } Object t =AssetDatabase.LoadMainAssetAtPath(localPath); if(t != null) { string bundlepath = "Assets/" + path + "/" +t.name + ".bytes"; BuildPipeline.BuildAssetBundle(t,null,bundlepath, option); } } } }}
阅读全文
0 0
- Tools(二)——BytesAdd
- GP学习(二)—Executing tools and Accesubg licensing0
- ArcToolbox使用之二——Data Managerment Tools
- pycaffe学习之(二)tools.py
- Bangu详解(二)--- Tools安装脚本
- Tools(一)——BuildMethod
- Tools(三)——CollsionDetection
- Tools(四)——FileU3DBuild
- Tools——PVRTrace
- Android源码浅析(二)——Ubuntu Root,Git,VMware Tools,安装输入法,主题美化,Dock,安装JDK和配置环境
- Delphi Open Tools Api实例研究(二)
- Delphi Open Tools Api实例研究(二)
- Delphi Open Tools Api实例研究(二)
- Delphi Open Tools Api实例研究(二)
- Wireless Tools Kit + J2ME 返朴归真(二)自己做游戏音乐!
- Development environment and tools of device driver(二)
- VMware安装Linux-Ubuntu系统(二)-安装vmware tools
- Tools——Snapdragon Profiler
- 系统间通信:网络I/O模型
- git学习
- thinkphp5.0调用云片接口实现发送短信验证码找回密码功能
- 对于web页面上某个显示框内部滚动条的滚动办法
- (网络安全)亲测可用的获取客户端IP的代码(java)
- Tools(二)——BytesAdd
- 实现兼容的isArray()方法
- java设计模式-桥接模式
- SARSA与Q-learning的区别
- JavaScript中的Window对象(重定向)
- python作业(面向对象)
- Advanced Format (4K扇区) 磁盘
- STL源码分析之vector(二)—核心函数 push_back及insert_aux
- 针对需要SHA1签名第三方SDK运行时和发布时签名不一致导致的无法调起