基于odin插件做的编辑器窗口(odin真香)。
根据文件类型赛选当前打包设置的场景里所有没有用到的资源,删除后会打包成package后删除,以免误删资源。
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using static System.Environment;
namespace YjjTool
{
public class Yjj_AssetClear : OdinEditorWindow
{
public enum FolderType
{
不清理文件夹内容,
只清理文件夹内容,
}
[Title("忽略文件类型")]
[EnumToggleButtons, HideLabel,InfoBox("<color=red>请注意:清理脚本文件和shader可能导致项目报错和材质丢失</color>",VisibleIf = "@!ignorType.HasFlag(IgnorType.cs) || !ignorType.HasFlag(IgnorType.shader)")]
public IgnorType ignorType = IgnorType.cs |IgnorType.shader;
[EnumToggleButtons, HideLabel, Space(15)]
public FolderType folderType = FolderType.不清理文件夹内容;
[LabelText("文件夹剔除"), InlineButton("Add")]
public List<string> ignorePath = new List<string>() { @"Assets\AllPlugins\YjjTools" };
[BoxGroup("list")]
[TableList(ShowIndexLabels = true), LabelText("可删除文件"),HideIf("@results.Count == 0")]
public List<ClearInfo> results = new List<ClearInfo>();
#region 快捷按钮
[BoxGroup("list", ShowLabel = false),HideIf("@results.Count == 0")]
[ButtonGroup("list/select")]
private void All()
{
results.ForEach(x => x.clear = true);
}
[BoxGroup("list")]
[ButtonGroup("list/select"), HideIf("@results.Count == 0")]
private void None()
{
results.ForEach(x => x.clear = false);
}
#endregion
[TableList(ShowIndexLabels = true), LabelText("谨慎删除的文件"),HideIf("@unSelectResults.Count == 0")]
public List<ClearInfo> unSelectResults = new List<ClearInfo>();
[TableList, ShowIf("@rules.Count>0"),LabelText("根据后缀选择文件")]
public List<TypeSelect> rules = new List<TypeSelect>();
private void Add()
{
var path = EditorUtility.OpenFolderPanel("选择要忽略的文件夹", Application.dataPath, "");
if (!string.IsNullOrEmpty(path))
{