mirror of https://github.com/tuyoogame/YooAsset
update asset art scanner
parent
7cc985205a
commit
ef4f011cf6
|
@ -7,7 +7,6 @@ using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor.UIElements;
|
using UnityEditor.UIElements;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
using UnityEngine.Tilemaps;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public enum EHeaderType
|
public enum EHeaderType
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 扫描模式
|
/// 扫描模式
|
||||||
|
/// 注意:文件路径或文件GUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ScannerSchema = string.Empty;
|
public string ScannerSchema = string.Empty;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ namespace YooAsset.Editor
|
||||||
private Label _schemaGuideTxt;
|
private Label _schemaGuideTxt;
|
||||||
private TextField _scannerNameTxt;
|
private TextField _scannerNameTxt;
|
||||||
private TextField _scannerDescTxt;
|
private TextField _scannerDescTxt;
|
||||||
private ObjectField _scanSchemaField;
|
private ObjectField _scannerSchemaField;
|
||||||
private ObjectField _saveFolderField;
|
private ObjectField _outputFolderField;
|
||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
|
|
||||||
private int _lastModifyScannerIndex = 0;
|
private int _lastModifyScannerIndex = 0;
|
||||||
|
@ -68,7 +68,10 @@ namespace YooAsset.Editor
|
||||||
_scannerListView = root.Q<ListView>("ScannerListView");
|
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||||
_scannerListView.makeItem = MakeScannerListViewItem;
|
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||||
_scannerListView.bindItem = BindScannerListViewItem;
|
_scannerListView.bindItem = BindScannerListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
|
#if UNITY_2022_3_OR_NEWER
|
||||||
|
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||||
|
#elif UNITY_2020_1_OR_NEWER
|
||||||
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
||||||
|
@ -120,22 +123,21 @@ namespace YooAsset.Editor
|
||||||
});
|
});
|
||||||
|
|
||||||
// 扫描模式
|
// 扫描模式
|
||||||
_scanSchemaField = root.Q<ObjectField>("ScanSchema");
|
_scannerSchemaField = root.Q<ObjectField>("ScanSchema");
|
||||||
_scanSchemaField.RegisterValueChangedCallback(evt =>
|
_scannerSchemaField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
if (selectScanner != null)
|
if (selectScanner != null)
|
||||||
{
|
{
|
||||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
_scanSchemaField.value.name = assetPath;
|
|
||||||
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 存储目录
|
// 存储目录
|
||||||
_saveFolderField = root.Q<ObjectField>("SaveFolder");
|
_outputFolderField = root.Q<ObjectField>("OutputFolder");
|
||||||
_saveFolderField.RegisterValueChangedCallback(evt =>
|
_outputFolderField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
if (selectScanner != null)
|
if (selectScanner != null)
|
||||||
|
@ -143,7 +145,6 @@ namespace YooAsset.Editor
|
||||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
if (AssetDatabase.IsValidFolder(assetPath))
|
||||||
{
|
{
|
||||||
_saveFolderField.value.name = assetPath;
|
|
||||||
selectScanner.SaveDirectory = assetPath;
|
selectScanner.SaveDirectory = assetPath;
|
||||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
}
|
}
|
||||||
|
@ -326,13 +327,13 @@ namespace YooAsset.Editor
|
||||||
var scanSchema = selectScanner.LoadSchema();
|
var scanSchema = selectScanner.LoadSchema();
|
||||||
if (scanSchema == null)
|
if (scanSchema == null)
|
||||||
{
|
{
|
||||||
_scanSchemaField.SetValueWithoutNotify(null);
|
_scannerSchemaField.SetValueWithoutNotify(null);
|
||||||
_schemaGuideTxt.text = string.Empty;
|
_schemaGuideTxt.text = string.Empty;
|
||||||
Selection.activeObject = null;
|
Selection.activeObject = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_scanSchemaField.SetValueWithoutNotify(scanSchema);
|
_scannerSchemaField.SetValueWithoutNotify(scanSchema);
|
||||||
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
||||||
Selection.activeObject = scanSchema;
|
Selection.activeObject = scanSchema;
|
||||||
}
|
}
|
||||||
|
@ -341,11 +342,11 @@ namespace YooAsset.Editor
|
||||||
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
||||||
if (saveFolder == null)
|
if (saveFolder == null)
|
||||||
{
|
{
|
||||||
_saveFolderField.SetValueWithoutNotify(null);
|
_outputFolderField.SetValueWithoutNotify(null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_saveFolderField.SetValueWithoutNotify(saveFolder);
|
_outputFolderField.SetValueWithoutNotify(saveFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
<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: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 Name" name="ScannerName" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
||||||
<uie:ObjectField label="Scan Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" />
|
<uie:ObjectField label="Scanner Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" allow-scene-objects="false" />
|
||||||
<uie:ObjectField label="Save Folder" name="SaveFolder" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" />
|
<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:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
<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:Button text="Scan" display-tooltip-when-elided="true" name="ScanBtn" style="width: 60px;" />
|
||||||
|
|
Loading…
Reference in New Issue