update AssetArtScanner

配置和报告容错性检测
This commit is contained in:
何冠峰
2025-02-10 16:21:43 +08:00
parent 7dfbac4a24
commit 2d6488abf4
9 changed files with 213 additions and 76 deletions
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using UnityEditor;
using UnityEngine;
@@ -46,6 +47,17 @@ namespace YooAsset.Editor
public List<string> WhiteList = new List<string>();
/// <summary>
/// 检测关键字匹配
/// </summary>
public bool CheckKeyword(string keyword)
{
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
return true;
else
return false;
}
/// <summary>
/// 是否在白名单里
/// </summary>
@@ -54,6 +66,24 @@ namespace YooAsset.Editor
return WhiteList.Contains(guid);
}
/// <summary>
/// 检测配置错误
/// </summary>
public void CheckConfigError()
{
if (string.IsNullOrEmpty(ScannerName))
throw new Exception($"Scanner name is null or empty !");
if (string.IsNullOrEmpty(ScannerSchema))
throw new Exception($"Scanner {ScannerName} schema is null !");
if (string.IsNullOrEmpty(SaveDirectory) == false)
{
if (Directory.Exists(SaveDirectory) == false)
throw new Exception($"Scanner {ScannerName} save directory is invalid : {SaveDirectory}");
}
}
/// <summary>
/// 加载扫描模式实例
/// </summary>
@@ -85,14 +115,11 @@ namespace YooAsset.Editor
public ScanReport RunScanner()
{
if (Collectors.Count == 0)
{
Debug.LogWarning($"Scanner collector is empty : {ScannerName}");
return null;
}
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
ScannerSchema schema = LoadSchema();
if (schema == null)
return null;
throw new Exception($"Failed to load schema : {ScannerSchema}");
var report = schema.RunScanner(this);
report.FileSign = ScannerDefine.ReportFileSign;
@@ -101,13 +128,5 @@ namespace YooAsset.Editor
report.ScannerGUID = ScannerGUID;
return report;
}
public bool CheckKeyword(string keyword)
{
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
return true;
else
return false;
}
}
}