IndieGame/client/Assets/Scripts/Config/Table/Editor/PropItem/PropItemTableWindow.cs

103 lines
3.1 KiB
C#
Raw Normal View History

using System;
2024-10-25 17:59:28 +08:00
using System.Collections.Generic;
using Sirenix.OdinInspector;
using TableConfig;
using UnityEditor;
using UnityEngine;
2024-10-25 17:59:28 +08:00
namespace Ether
{
public class PropItemTableWindow : OdinSubWindowBase
2024-10-25 17:59:28 +08:00
{
[LabelText("道具列表")]
[DisableContextMenu(true, true)]
2024-10-25 17:59:28 +08:00
[TableList(IsReadOnly = true, AlwaysExpanded = true), ShowInInspector]
private List<PropItemTableEditorPreview> propItemTableEditorPreviewList;
2024-10-25 17:59:28 +08:00
protected override void OnInit()
2024-10-25 17:59:28 +08:00
{
propItemTableEditorPreviewList = new List<PropItemTableEditorPreview>();
}
public override void OnShow()
{
propItemTableEditorPreviewList.Clear();
foreach (var propItemCfg in TableProvider.Tables.TbPropItem.DataList)
{
propItemTableEditorPreviewList.Add(new PropItemTableEditorPreview(propItemCfg));
}
}
protected override void OnSave()
{
Debug.Log("Custom save action performed.");
// 在这里添加你的保存逻辑
}
2024-10-25 17:59:28 +08:00
}
[DisableContextMenu(true, true)]
2024-10-25 17:59:28 +08:00
public class PropItemTableEditorPreview
{
[DisableContextMenu]
[TableColumnWidth(50, false)]
[HorizontalGroup("Id"), HideLabel]
[ShowInInspector]
[DisplayAsString]
[LabelWidth(20)]
[Center]
public int Id;
[DisableContextMenu]
[HorizontalGroup("图标"), HideLabel]
[TableColumnWidth(50, false)]
[ShowInInspector, PreviewField(45, ObjectFieldAlignment.Center)]
[ReadOnly]
public Texture Icon;
[DisableContextMenu]
[HorizontalGroup("名称"), HideLabel]
[TableColumnWidth(150, false)]
[DisplayAsString]
[Center]
public string Name;
[DisableContextMenu]
[HorizontalGroup("类型"), HideLabel]
[TableColumnWidth(150, false)]
[DisplayAsString]
[Center]
public PropItemType Type;
[DisableContextMenu]
[HorizontalGroup("品质"), HideLabel]
[TableColumnWidth(50, false)]
[DisplayAsString]
[Center]
public int Quality;
[DisableContextMenu]
[HorizontalGroup("描述"), HideLabel]
[TableColumnWidth(0)]
//[TextArea(2,100)]
//[ReadOnly]
[Center]
public string Description = "这是个道具描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述 ";
public PropItemTableEditorPreview(PropItemTable propItemCfg)
{
if (!string.IsNullOrEmpty(propItemCfg.Icon))
{
Icon = LoaderTools.LoadAsset<Sprite>("Art/UI/Icon/" + propItemCfg.Icon).texture;
//Icon = AssetDatabase.LoadAssetAtPath<Texture>("Resources/" + );
}
Id = propItemCfg.Id;
Name = propItemCfg.Name;
Type = propItemCfg.Type;
Quality = propItemCfg.Quality;
Description = propItemCfg.Description;
}
}
}