mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
TEngine 6
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描目录
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e7252b59455e5c45af0041ccd24b234
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtScanner
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器GUID
|
||||
/// </summary>
|
||||
public string ScannerGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器名称
|
||||
/// </summary>
|
||||
public string ScannerName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器描述
|
||||
/// </summary>
|
||||
public string ScannerDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描模式
|
||||
/// 注意:文件路径或文件GUID
|
||||
/// </summary>
|
||||
public string ScannerSchema = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 存储目录
|
||||
/// </summary>
|
||||
public string SaveDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集列表
|
||||
/// </summary>
|
||||
public List<AssetArtCollector> Collectors = new List<AssetArtCollector>();
|
||||
|
||||
/// <summary>
|
||||
/// 白名单
|
||||
/// </summary>
|
||||
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>
|
||||
public bool CheckWhiteList(string guid)
|
||||
{
|
||||
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>
|
||||
public ScannerSchema LoadSchema()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
return null;
|
||||
|
||||
string filePath;
|
||||
if (ScannerSchema.StartsWith("Assets/"))
|
||||
{
|
||||
filePath = ScannerSchema;
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = ScannerSchema;
|
||||
filePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
}
|
||||
|
||||
var schema = AssetDatabase.LoadMainAssetAtPath(filePath) as ScannerSchema;
|
||||
if (schema == null)
|
||||
Debug.LogWarning($"Failed load scanner schema : {filePath}");
|
||||
return schema;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行扫描器生成报告类
|
||||
/// </summary>
|
||||
public ScanReport RunScanner()
|
||||
{
|
||||
if (Collectors.Count == 0)
|
||||
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
|
||||
|
||||
ScannerSchema schema = LoadSchema();
|
||||
if (schema == null)
|
||||
throw new Exception($"Failed to load schema : {ScannerSchema}");
|
||||
|
||||
var report = schema.RunScanner(this);
|
||||
report.FileSign = ScannerDefine.ReportFileSign;
|
||||
report.FileVersion = ScannerDefine.ReportFileVersion;
|
||||
report.SchemaType = schema.GetType().FullName;
|
||||
report.ScannerGUID = ScannerGUID;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c63683b07b7a2454b93539ae6b9f32ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerConfig
|
||||
{
|
||||
public class ConfigWrapper
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件签名
|
||||
/// </summary>
|
||||
public string FileSign;
|
||||
|
||||
/// <summary>
|
||||
/// 文件版本
|
||||
/// </summary>
|
||||
public string FileVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入JSON配置文件
|
||||
/// </summary>
|
||||
public static void ImportJsonConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
string json = FileUtility.ReadAllText(filePath);
|
||||
ConfigWrapper setting = JsonUtility.FromJson<ConfigWrapper>(json);
|
||||
|
||||
// 检测配置文件的签名
|
||||
if (setting.FileSign != ScannerDefine.SettingFileSign)
|
||||
throw new Exception($"导入的配置文件无法识别 : {filePath}");
|
||||
|
||||
// 检测配置文件的版本
|
||||
if (setting.FileVersion != ScannerDefine.SettingFileVersion)
|
||||
throw new Exception($"配置文件的版本不匹配 : {setting.FileVersion} != {ScannerDefine.SettingFileVersion}");
|
||||
|
||||
// 检测配置合法性
|
||||
HashSet<string> scanGUIDs = new HashSet<string>();
|
||||
foreach (var sacnner in setting.Scanners)
|
||||
{
|
||||
if (scanGUIDs.Contains(sacnner.ScannerGUID))
|
||||
{
|
||||
throw new Exception($"Scanner {sacnner.ScannerName} GUID is existed : {sacnner.ScannerGUID} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
scanGUIDs.Add(sacnner.ScannerGUID);
|
||||
}
|
||||
}
|
||||
|
||||
AssetArtScannerSettingData.Setting.Scanners = setting.Scanners;
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出JSON配置文件
|
||||
/// </summary>
|
||||
public static void ExportJsonConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
ConfigWrapper wrapper = new ConfigWrapper();
|
||||
wrapper.FileSign = ScannerDefine.SettingFileSign;
|
||||
wrapper.FileVersion = ScannerDefine.SettingFileVersion;
|
||||
wrapper.Scanners = AssetArtScannerSettingData.Setting.Scanners;
|
||||
|
||||
string json = JsonUtility.ToJson(wrapper, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bed1ef72d1c03e848a41d5ea115e9870
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
|
||||
/// <summary>
|
||||
/// 开始扫描
|
||||
/// </summary>
|
||||
public ScannerResult BeginScan(string scannerGUID)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取扫描器配置
|
||||
var scanner = GetScanner(scannerGUID);
|
||||
if (scanner == null)
|
||||
throw new Exception($"Invalid scanner GUID : {scannerGUID}");
|
||||
|
||||
// 检测配置合法性
|
||||
scanner.CheckConfigError();
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的扫描器
|
||||
/// </summary>
|
||||
public AssetArtScanner GetScanner(string scannerGUID)
|
||||
{
|
||||
foreach (var scanner in Scanners)
|
||||
{
|
||||
if (scanner.ScannerGUID == scannerGUID)
|
||||
return scanner;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84df5e62e3f1b6746a1263e076b003e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSettingData
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
static AssetArtScannerSettingData()
|
||||
{
|
||||
}
|
||||
|
||||
private static AssetArtScannerSetting _setting = null;
|
||||
public static AssetArtScannerSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
_setting = SettingLoader.LoadSettingData<AssetArtScannerSetting>();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetArtScannerSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.Scanners.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll()
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll(string keyword)
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyword) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(keyword) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描单项
|
||||
/// </summary>
|
||||
public static ScannerResult Scan(string scannerGUID)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError(scanResult.ErrorInfo);
|
||||
}
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
// 扫描器编辑相关
|
||||
public static AssetArtScanner CreateScanner(string name, string desc)
|
||||
{
|
||||
AssetArtScanner scanner = new AssetArtScanner();
|
||||
scanner.ScannerGUID = System.Guid.NewGuid().ToString();
|
||||
scanner.ScannerName = name;
|
||||
scanner.ScannerDesc = desc;
|
||||
Setting.Scanners.Add(scanner);
|
||||
IsDirty = true;
|
||||
return scanner;
|
||||
}
|
||||
public static void RemoveScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (Setting.Scanners.Remove(scanner))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove scanner : {scanner.ScannerName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (scanner != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集编辑相关
|
||||
public static void CreateCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
scanner.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fda10f23f6f36bf498b54323fe4f680b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,544 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetArt Scanner", false, 301)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetArtScannerWindow window = GetWindow<AssetArtScannerWindow>("AssetArt Scanner", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private Button _saveButton;
|
||||
private ListView _scannerListView;
|
||||
private ToolbarSearchField _scannerSearchField;
|
||||
private VisualElement _scannerContentContainer;
|
||||
private VisualElement _inspectorContainer;
|
||||
private Label _schemaGuideTxt;
|
||||
private TextField _scannerNameTxt;
|
||||
private TextField _scannerDescTxt;
|
||||
private ObjectField _scannerSchemaField;
|
||||
private ObjectField _outputFolderField;
|
||||
private ScrollView _collectorScrollView;
|
||||
|
||||
private int _lastModifyScannerIndex = 0;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
Undo.undoRedoPerformed -= RefreshWindow;
|
||||
Undo.undoRedoPerformed += RefreshWindow;
|
||||
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtScannerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_clicked;
|
||||
|
||||
// 配置保存按钮
|
||||
_saveButton = root.Q<Button>("SaveButton");
|
||||
_saveButton.clicked += SaveBtn_clicked;
|
||||
|
||||
// 扫描按钮
|
||||
var scanAllBtn = root.Q<Button>("ScanAllButton");
|
||||
scanAllBtn.clicked += ScanAllBtn_clicked;
|
||||
var scanBtn = root.Q<Button>("ScanBtn");
|
||||
scanBtn.clicked += ScanBtn_clicked;
|
||||
|
||||
// 扫描列表相关
|
||||
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||
_scannerListView.bindItem = BindScannerListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
||||
#else
|
||||
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 扫描列表过滤
|
||||
_scannerSearchField = root.Q<ToolbarSearchField>("ScannerSearchField");
|
||||
_scannerSearchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 扫描器添加删除按钮
|
||||
var scannerAddContainer = root.Q("ScannerAddContainer");
|
||||
{
|
||||
var addBtn = scannerAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddScannerBtn_clicked;
|
||||
var removeBtn = scannerAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveScannerBtn_clicked;
|
||||
}
|
||||
|
||||
// 扫描器容器
|
||||
_scannerContentContainer = root.Q("ScannerContentContainer");
|
||||
|
||||
// 检视界面容器
|
||||
_inspectorContainer = root.Q("InspectorContainer");
|
||||
|
||||
// 扫描器指南
|
||||
_schemaGuideTxt = root.Q<Label>("SchemaUserGuide");
|
||||
|
||||
// 扫描器名称
|
||||
_scannerNameTxt = root.Q<TextField>("ScannerName");
|
||||
_scannerNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerName = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描器备注
|
||||
_scannerDescTxt = root.Q<TextField>("ScannerDesc");
|
||||
_scannerDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerDesc = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描模式
|
||||
_scannerSchemaField = root.Q<ObjectField>("ScanSchema");
|
||||
_scannerSchemaField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
});
|
||||
|
||||
// 存储目录
|
||||
_outputFolderField = root.Q<ObjectField>("OutputFolder");
|
||||
_outputFolderField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
if (evt.newValue == null)
|
||||
{
|
||||
selectScanner.SaveDirectory = string.Empty;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
{
|
||||
selectScanner.SaveDirectory = assetPath;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Select asset object not folder ! {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 收集列表相关
|
||||
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||
_collectorScrollView.viewDataKey = "scrollView";
|
||||
|
||||
// 收集器创建按钮
|
||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||
{
|
||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddCollectorBtn_clicked;
|
||||
}
|
||||
|
||||
// 刷新窗体
|
||||
RefreshWindow();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 注意:清空所有撤销操作
|
||||
Undo.ClearAll();
|
||||
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (_saveButton != null)
|
||||
{
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
{
|
||||
if (_saveButton.enabledSelf == false)
|
||||
_saveButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_saveButton.enabledSelf)
|
||||
_saveButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ExportJsonConfig($"{resultPath}/AssetArtScannerConfig.json");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFilePath("Import JSON", "Assets/", "json");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ImportJsonConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
private void ScanAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始全面扫描!", "Yes", "No"))
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
AssetArtScannerSettingData.ScanAll(searchKeyWord);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("全面扫描已经取消");
|
||||
}
|
||||
}
|
||||
private void ScanBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
ScannerResult scannerResult = AssetArtScannerSettingData.Scan(selectScanner.ScannerGUID);
|
||||
if (scannerResult.Succeed)
|
||||
{
|
||||
// 自动打开报告界面
|
||||
scannerResult.OpenReportWindow();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_lastModifyScannerIndex = 0;
|
||||
RefreshWindow();
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillScannerListViewData()
|
||||
{
|
||||
_scannerListView.Clear();
|
||||
_scannerListView.ClearSelection();
|
||||
|
||||
var filterItems = FilterScanners();
|
||||
if (AssetArtScannerSettingData.Setting.Scanners.Count == filterItems.Count)
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = true;
|
||||
#endif
|
||||
_scannerListView.itemsSource = AssetArtScannerSettingData.Setting.Scanners;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = false;
|
||||
#endif
|
||||
_scannerListView.itemsSource = filterItems;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
}
|
||||
private List<AssetArtScanner> FilterScanners()
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
List<AssetArtScanner> result = new List<AssetArtScanner>(AssetArtScannerSettingData.Setting.Scanners.Count);
|
||||
|
||||
// 过滤列表
|
||||
foreach (var scanner in AssetArtScannerSettingData.Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(scanner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private VisualElement MakeScannerListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.height = 20f;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindScannerListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<AssetArtScanner> sourceList = _scannerListView.itemsSource as List<AssetArtScanner>;
|
||||
var scanner = sourceList[index];
|
||||
var textField1 = element.Q<Label>("Label1");
|
||||
if (string.IsNullOrEmpty(scanner.ScannerDesc))
|
||||
textField1.text = scanner.ScannerName;
|
||||
else
|
||||
textField1.text = $"{scanner.ScannerName} ({scanner.ScannerDesc})";
|
||||
}
|
||||
private void ScannerListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_scannerContentContainer.visible = true;
|
||||
_lastModifyScannerIndex = _scannerListView.selectedIndex;
|
||||
_scannerNameTxt.SetValueWithoutNotify(selectScanner.ScannerName);
|
||||
_scannerDescTxt.SetValueWithoutNotify(selectScanner.ScannerDesc);
|
||||
|
||||
// 显示检视面板
|
||||
var scanSchema = selectScanner.LoadSchema();
|
||||
RefreshInspector(scanSchema);
|
||||
|
||||
// 设置Schema对象
|
||||
if (scanSchema == null)
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(null);
|
||||
_schemaGuideTxt.text = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(scanSchema);
|
||||
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
||||
}
|
||||
|
||||
// 显示存储目录
|
||||
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
||||
if (saveFolder == null)
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(saveFolder);
|
||||
}
|
||||
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void AddScannerBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddScanner");
|
||||
AssetArtScannerSettingData.CreateScanner("Default Scanner", string.Empty);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void RemoveScannerBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveScanner");
|
||||
AssetArtScannerSettingData.RemoveScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectScanner.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
_collectorScrollView.Add(element);
|
||||
}
|
||||
}
|
||||
private VisualElement MakeCollectorListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
VisualElement elementTop = new VisualElement();
|
||||
elementTop.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementTop);
|
||||
|
||||
VisualElement elementSpace = new VisualElement();
|
||||
elementSpace.style.flexDirection = FlexDirection.Column;
|
||||
element.Add(elementSpace);
|
||||
|
||||
// Top VisualElement
|
||||
{
|
||||
var button = new Button();
|
||||
button.name = "Button1";
|
||||
button.text = "-";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.style.flexGrow = 0f;
|
||||
elementTop.Add(button);
|
||||
}
|
||||
{
|
||||
var objectField = new ObjectField();
|
||||
objectField.name = "ObjectField1";
|
||||
objectField.label = "Collector";
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
objectField.style.flexGrow = 1f;
|
||||
elementTop.Add(objectField);
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
|
||||
// Space VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.height = 10;
|
||||
elementSpace.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
var collector = selectScanner.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
removeBtn.clicked += () =>
|
||||
{
|
||||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Collector Path
|
||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||
objectField1.SetValueWithoutNotify(collectObject);
|
||||
objectField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetArtScannerSettingData.ModifyCollector(selectScanner, collector);
|
||||
});
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddCollector");
|
||||
AssetArtCollector collector = new AssetArtCollector();
|
||||
AssetArtScannerSettingData.CreateCollector(selectSacnner, collector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetArtCollector selectCollector)
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveCollector");
|
||||
AssetArtScannerSettingData.RemoveCollector(selectSacnner, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
// 属性面板相关
|
||||
private void RefreshInspector(ScannerSchema scanSchema)
|
||||
{
|
||||
if (scanSchema == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var inspector = scanSchema.CreateInspector();
|
||||
if (inspector == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspector.Containner is VisualElement container)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||
_inspectorContainer.Clear();
|
||||
_inspectorContainer.Add(container);
|
||||
_inspectorContainer.style.width = inspector.Width;
|
||||
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bff583b32bbeb7e498920bfdc84dba90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Scan All" display-tooltip-when-elided="true" name="ScanAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="ScannerListContainer" style="width: 250px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Scanner List" display-tooltip-when-elided="true" name="ScannerListTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; font-size: 12px;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="ScannerSearchField" style="width: 230px;" />
|
||||
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" reorder-mode="Animated" reorderable="true" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="ScannerAddContainer" style="justify-content: center; flex-direction: row; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ScannerContentContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; min-width: 400px;">
|
||||
<ui:Label text="Scanner" display-tooltip-when-elided="true" name="ScannerContentTitle" style="-unity-text-align: upper-center; -unity-font-style: bold; font-size: 12px; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; background-color: rgb(89, 89, 89);" />
|
||||
<ui:Label display-tooltip-when-elided="true" name="SchemaUserGuide" style="-unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px; height: 40px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Name" name="ScannerName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
||||
<uie:ObjectField label="Scanner Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" allow-scene-objects="false" />
|
||||
<uie:ObjectField label="Output Folder" name="OutputFolder" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
<ui:Button text="Scan" display-tooltip-when-elided="true" name="ScanBtn" style="width: 60px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="InspectorContainer" style="flex-grow: 1; border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px; background-color: rgb(67, 67, 67);" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bbb873a7bee2924a86c876b67bb2cb4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
@@ -0,0 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 报告文件签名
|
||||
/// </summary>
|
||||
public const string ReportFileSign = "596f6f4172745265706f7274";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件签名
|
||||
/// </summary>
|
||||
public const string SettingFileSign = "596f6f41727453657474696e67";
|
||||
|
||||
/// <summary>
|
||||
/// 报告文件的版本
|
||||
/// </summary>
|
||||
public const string ReportFileVersion = "1.0";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件的版本
|
||||
/// </summary>
|
||||
public const string SettingFileVersion = "1.0";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed658bfc32cbfc44caf262a741a7c387
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,59 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成的报告文件路径
|
||||
/// </summary>
|
||||
public string ReprotFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告对象
|
||||
/// </summary>
|
||||
public ScanReport Report { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool Succeed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(ErrorInfo))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ScannerResult(string error)
|
||||
{
|
||||
ErrorInfo = error;
|
||||
}
|
||||
public ScannerResult(string filePath, ScanReport report)
|
||||
{
|
||||
ReprotFilePath = filePath;
|
||||
Report = report;
|
||||
ErrorInfo = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开报告窗口
|
||||
/// </summary>
|
||||
public void OpenReportWindow()
|
||||
{
|
||||
if (Succeed)
|
||||
{
|
||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||
reproterWindow.ImportSingleReprotFile(ReprotFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e10cdab189d80b142ad5903d12956c59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public abstract class ScannerSchema : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户指南信息
|
||||
/// </summary>
|
||||
public abstract string GetUserGuide();
|
||||
|
||||
/// <summary>
|
||||
/// 运行生成扫描报告
|
||||
/// </summary>
|
||||
public abstract ScanReport RunScanner(AssetArtScanner scanner);
|
||||
|
||||
/// <summary>
|
||||
/// 修复扫描结果
|
||||
/// </summary>
|
||||
public abstract void FixResult(List<ReportElement> fixList);
|
||||
|
||||
/// <summary>
|
||||
/// 创建检视面板
|
||||
/// </summary>
|
||||
public virtual SchemaInspector CreateInspector()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb6a587c72ccecc4ab6d386063cf0736
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,45 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class SchemaInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// 检视界面的UI元素容器(UIElements元素)
|
||||
/// </summary>
|
||||
public object Containner { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面宽度
|
||||
/// </summary>
|
||||
public int Width = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最小宽度
|
||||
/// </summary>
|
||||
public int MinWidth = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = 250;
|
||||
|
||||
public SchemaInspector(object containner)
|
||||
{
|
||||
Containner = containner;
|
||||
}
|
||||
public SchemaInspector(object containner, int width)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public SchemaInspector(object containner, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3440549fcb36bbf4c8c6da17fb858947
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user