BITFALL/Assets/Artists/Scripts/Editors/ItemSOEditor.cs

78 lines
2.4 KiB
C#

/* using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BITKit;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using System.Linq;
using BITKit.UX;
using UnityEngine.AddressableAssets;
namespace BITFALL
{
public class ItemSOEditor : EditorWindow
{
VisualElement root;
ListView listView;
VisualElement inspector;
List<InGameObjectsBase> gameobjects;
[MenuItem("Tools/ItemSO Editor")]
static void Open()
{
var window = EditorWindow.GetWindow<ItemSOEditor>();
//window.titleContent = new("Reference Editor");
window.Show();
}
public void CreateGUI()
{
root = Addressables.LoadAssetAsync<VisualTreeAsset>(nameof(ItemSOEditor)).WaitForCompletion().CloneTree();
rootVisualElement.Add(root);
listView = root.Q<ListView>(UXConstant.ContextListView);
inspector = root.Q(UXConstant.Inspector);
gameobjects = AssetDatabase
.FindAssets($"t:{nameof(InGameObjectsBase)}")
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Select(x => AssetDatabase.LoadAssetAtPath<InGameObjectsBase>(x))
.ToList();
listView.makeItem = MakeItem;
listView.bindItem = Bind;
listView.onSelectedIndicesChange += OnSelectedIndicesChange;
listView.itemsSource = gameobjects;
}
VisualElement MakeItem()
{
var root = new VisualElement();
var label = new Label();
label.name = UXConstant.ContextLabel;
var icon = new VisualElement();
icon.name = UXConstant.Icon;
root.Add(label);
root.Add(icon);
return root;
}
void Bind(VisualElement visualElement, int index)
{
var _ = gameobjects[index];
visualElement.Q<Label>(UXConstant.ContextLabel).text = _.name;
visualElement.Q(UXConstant.Icon).style.backgroundImage = new(_.Icon);
}
void OnSelectedIndicesChange(IEnumerable<int> indexs)
{
if (indexs.Count() == 1)
{
var selected = gameobjects[indexs.First()];
BITInspector<InGameItem>.FillDefaultInspector(inspector, new(selected), true);
}
}
}
}
*/