47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
![]() |
#if UNITY_EDITOR
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using BITKit;
|
||
|
using BITKit.GameEditor;
|
||
|
using Project.B.Item;
|
||
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using Button = UnityEngine.UIElements.Button;
|
||
|
|
||
|
namespace Net.Project.B.Loot
|
||
|
{
|
||
|
public class ScriptableLootEditorWindow : ScriptableObjectGroupEditor<ScriptableLoot>
|
||
|
{
|
||
|
protected override string AssetsPath => "Assets/Artists/Configs/Loots";
|
||
|
[MenuItem("Tools/Scriptable Editor/Loot")]
|
||
|
public static void Open()
|
||
|
{
|
||
|
GetWindow<ScriptableLootEditorWindow>().Show();
|
||
|
}
|
||
|
|
||
|
protected override void OnEnable()
|
||
|
{
|
||
|
base.OnEnable();
|
||
|
{
|
||
|
var button = ToolBarContainer.Create<Button>();
|
||
|
button.text = $"从已选的{nameof(ScriptableItem)}添加进入{nameof(ScriptableLoot)}";
|
||
|
button.clicked += AddFromSelection;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void AddFromSelection()
|
||
|
{
|
||
|
if (listView.selectedItem is not ScriptableLoot scriptableLoot) return;
|
||
|
foreach (var item in Selection.objects.OfType<ScriptableItem>())
|
||
|
{
|
||
|
if (scriptableLoot.itemWeights.ContainsKey(item)) continue;
|
||
|
scriptableLoot.itemWeights.AddConflictAllowed(item, 1);
|
||
|
}
|
||
|
EditorUtility.SetDirty(scriptableLoot);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endif
|