52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
#if UNITY_EDITOR
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace DDD
|
|
{
|
|
[Serializable]
|
|
public class TestItemEntry
|
|
{
|
|
[ValueDropdown(nameof(GetAllItemIds))]
|
|
public string ItemId;
|
|
|
|
[MinValue(1)]
|
|
public int Quantity = 1;
|
|
|
|
private IEnumerable<string> GetAllItemIds()
|
|
{
|
|
var itemSo = LoadItemDataSo();
|
|
if (itemSo == null)
|
|
return Array.Empty<string>();
|
|
|
|
return itemSo.GetDataList()
|
|
.Where(d => !string.IsNullOrEmpty(d.Id))
|
|
.Select(d => d.Id);
|
|
}
|
|
|
|
private ItemDataSo LoadItemDataSo()
|
|
{
|
|
// 경로는 프로젝트에 맞게 조정 필요
|
|
string[] guids = AssetDatabase.FindAssets("t:ItemDataSo");
|
|
if (guids.Length == 0) return null;
|
|
|
|
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
|
return AssetDatabase.LoadAssetAtPath<ItemDataSo>(path);
|
|
}
|
|
}
|
|
|
|
[CreateAssetMenu(menuName = "Test/InventoryTestDataSo", fileName = "InventoryTestDataSo")]
|
|
public class InventoryTestDataSo : ScriptableObject
|
|
{
|
|
[LabelText("테스트 데이터 적용 여부")]
|
|
public bool UseTestData;
|
|
|
|
[LabelText("테스트용 아이템 목록"), ListDrawerSettings]
|
|
public List<TestItemEntry> TestItems = new();
|
|
}
|
|
}
|
|
#endif |