资源简介
随着项目的研发进度,Asset数量也会爆发式地增长,资源管理面临很大的挑战。如何查找并区分有效和无效的资源,是很多项目管理者非常重视的事情。本文介绍的这个工具可以自动分析查找项目中未使用到的资源,在选择删除的时候还可以将这些文件打包备份,确保资源的安全性、提高项目管理的效率。
代码片段和文件信息
/**
asset cleaner
Copyright (c) 2015 Tatsuhiko Yamamura
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using System.IO;
using System.Text.Regularexpressions;
namespace AssetClean
{
public class AssetCollector
{
public List deleteFileList = new List ();
ClassReferenceCollection classCollection = new ClassReferenceCollection ();
ShaderReferenceCollection shaderCollection = new ShaderReferenceCollection ();
public bool useCodeStrip = true;
public bool saveEditorExtensions = true;
public void Collection ()
{
try {
deleteFileList.Clear ();
if( useCodeStrip ){
classCollection.Collection ();
}
shaderCollection.Collection ();
// Find assets
var files = Directory.GetFiles (“Assets“ “*.*“ SearchOption.AllDirectories)
.Where (item => Path.GetExtension (item) != “.meta“)
.Where (item => Path.GetExtension (item) != “.js“)
.Where (item => Path.GetExtension (item) != “.dll“)
.Where (item => Regex.IsMatch (item “[\\/\\\\]Gizmos[\\/\\\\]“) == false)
.Where (item => Regex.IsMatch (item “[\\/\\\\]Plugins[\\/\\\\]Android[\\/\\\\]“) == false)
.Where (item => Regex.IsMatch (item “[\\/\\\\]Plugins[\\/\\\\]iOS[\\/\\\\]“) == false)
.Where (item => Regex.IsMatch (item “[\\/\\\\]Resources[\\/\\\\]“) == false);
if( useCodeStrip == false ){
files = files.Where( item => Path.GetExtension(item) != “.cs“);
}
foreach (var path in files) {
var guid = AssetDatabase.AssetPathToGUID (path);
deleteFileList.Add (guid);
}
EditorUtility.DisplayProgressBar (“checking“ “collection all files“ 0.2f);
UnregistReferenceFromResources();
EditorUtility.DisplayProgressBar (“checking“ “check reference from resources“ 0.4f);
UnregistReferenceFromScenes();
EditorUtility.DisplayProgressBar (“checking“ “check reference from scenes“ 0.6f);
if( saveEditorExtensions ){
UnregistEditorCodes();
}
} finally {
EditorUtility.ClearProgressBar ();
}
}
void UnregistReferenceFromResources()
{
var resourcesFiles = Directory.GetFiles (“Assets“ “*.*“ SearchOption.AllDirectories)
.Where (item => Regex.IsMatch (item “[\\/\\\\]Resources[\\/\\\\]“) == true)
.Where (item => Path.GetExtension (item) != “.meta“)
.ToArray ();
foreach (var path in AssetDatabase.GetDependencies (resourcesFiles)) {
UnregistFromDelteList (AssetDatabase.AssetPathToGUID(path));
}
}
void UnregistReferenceFromScenes()
{
// Exclude objects that reference from scenes.
var scenes = EditorBuildSettings.scenes
.Where (item => item.enabled == true)
.Select (item => item.path)
.ToArray ();
foreach (var path in AssetDatabase.GetDependencies (scenes)) {
if( saveEditorExtensions == false ){
Debug.Log(path);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-07-26 14:42 Tool-UnityAssetCleaner-master\
文件 263 2015-07-26 14:42 Tool-UnityAssetCleaner-master\.gitignore
目录 0 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\
文件 192 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner.me
目录 0 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\
文件 192 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor.me
目录 0 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\
文件 5013 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\AssetCollector.cs
文件 262 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\AssetCollector.cs.me
文件 6320 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\ClassReferenceCollection.cs
文件 262 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\ClassReferenceCollection.cs.me
文件 4751 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\FindUnusedAssets.cs
文件 262 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\FindUnusedAssets.cs.me
文件 2307 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\ShaderReferenceCollection.cs
文件 262 2015-07-26 14:42 Tool-UnityAssetCleaner-master\Assets\Cleaner\Editor\ShaderReferenceCollection.cs.me
文件 1086 2015-07-26 14:42 Tool-UnityAssetCleaner-master\LICENSE
目录 0 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\
文件 4136 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\AudioManager.asset
文件 4276 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\DynamicsManager.asset
文件 4104 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\EditorBuildSettings.asset
文件 4188 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\EditorSettings.asset
文件 4228 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\GraphicsSettings.asset
文件 5520 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\InputManager.asset
文件 4384 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\NavMeshAreas.asset
文件 4112 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\NetworkManager.asset
文件 4308 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\Physics2DSettings.asset
文件 35901 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\ProjectSettings.asset
文件 52 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\ProjectVersion.txt
文件 4944 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\QualitySettings.asset
文件 4236 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\TagManager.asset
文件 4112 2015-07-26 14:42 Tool-UnityAssetCleaner-master\ProjectSettings\TimeManager.asset
............此处省略1个文件信息
- 上一篇:deap 2.1 带的奥
- 下一篇:数理统计复习总结
相关资源
- unity4.0官方正式版
- Behavior Designer 1.6.3(u2018.3.0).unitypa
- Unity纪念碑谷.rar
- A Pathfinding Project Pro v4.2.2.rar
- Unity 声音播放插件,支持将字符串转
- Gaia 1.7.2
- Unity3d实现扭动挤压浏览效果
- UnityShader卷轴效果
- 爱酱(绊爱Kizuna)模型
- 遗传算法越野小车unity5.5
- unity 3D 百度语音合成 并播放
- unity案例入门坦克大战源码
- 高效秒杀抢杀器
- Graph And Chart 1.91.unitypackage
- Animated Steel Coaster 1.51.rar
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- unity3d_见缝插针源码及报告.zip
- Unity3d车库场景模型
- unity3d 警察动画模型
- unity20多种烟雾以及爆炸特效
- unity博物馆.zip
- burpsuite_community社区版x86系统
- unity3D 新手引导遮罩,支持圆形和矩形
- 兼容unity的System.Drawing.dll
- unity3d枪支武器包FPS第一人称射击游戏
- UniWebView 3.unitypackage
- unity2D猛禽战机空战游戏完整源码
- Final IK 1.9
评论
共有 条评论