50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
#if UNITY_EDITOR
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BITKit;
|
|
using BITKit.GameEditor;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Net.Project.B.Inventory;
|
|
using Project.B.Item;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Net.Project.B.Inventory
|
|
{
|
|
public class ScriptableBuyStationEditorWindow : ScriptableObjectGroupEditor<ScriptableBuyStationItemList>
|
|
{
|
|
protected override string AssetsPath => "Assets/Artists/Configs/BuyStation";
|
|
[MenuItem("Tools/Scriptable Editor/Buy Station")]
|
|
public static void Open()
|
|
{
|
|
GetWindow<ScriptableBuyStationEditorWindow>().Show();
|
|
}
|
|
protected override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
{
|
|
var button = ToolBarContainer.Create<Button>();
|
|
button.text = $"从已选的{nameof(ScriptableItem)}添加进入{nameof(ScriptableBuyStationItemList)}";
|
|
button.clicked += AddFromSelection;
|
|
}
|
|
}
|
|
|
|
private void AddFromSelection()
|
|
{
|
|
if (listView.selectedItem is not ScriptableBuyStationItemList so) return;
|
|
foreach (var item in Selection.objects.OfType<ScriptableItem>())
|
|
{
|
|
if(so.ItemList.Any(x=>x.ScriptableId == item.Id))continue;
|
|
so.itemList.Add(new ScriptableBuyStationItemList.ItemInfo()
|
|
{
|
|
scriptableItem=item,
|
|
});
|
|
}
|
|
EditorUtility.SetDirty(so);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |