com.alicizax.unity/Editor/EditorWindow/GameFrameworkPreferenceWindow.cs
2025-03-07 17:58:52 +08:00

98 lines
3.6 KiB
C#

// using UnityEditor;
// using UnityEngine;
// using System;
// using System.Linq;
// using System.Reflection;
// using System.Collections.Generic;
// using AlicizaX.Runtime;
// using Sirenix.OdinInspector.Editor;
//
// namespace AlicizaX.Editor
// {
// public class GameFrameworkPreferenceWindow : OdinMenuEditorWindow
// {
// private List<Type> m_TabTypes;
// private readonly Dictionary<Type, GameFrameworkTabBase> _tabBases = new();
//
// [MenuItem("Tools/AlicizaX/Preference Window")]
// public static void ShowWindow()
// {
// GetWindow<GameFrameworkPreferenceWindow>(true, "Preference Window");
// }
//
// protected override void OnEnable()
// {
// base.OnEnable();
// this.position = new Rect(this.position.x, this.position.y, 800, 600);
//
// var assemblies = Utility.Assembly.GetAssemblies();
//
// m_TabTypes = new List<Type>();
//
// foreach (var assembly in assemblies)
// {
// var types = assembly.GetTypes();
// foreach (var type in types)
// {
// if (typeof(GameFrameworkTabBase).IsAssignableFrom(type) && type.IsClass && !type.IsAbstract)
// {
// var displayNameAttr = (DisplayNameAttribute)Attribute.GetCustomAttribute(type, typeof(DisplayNameAttribute));
// if (displayNameAttr != null)
// {
// m_TabTypes.Add(type);
// }
// }
// }
// }
//
// m_TabTypes = m_TabTypes.OrderBy(t => ((DisplayNameAttribute)Attribute.GetCustomAttribute(t, typeof(DisplayNameAttribute))).DisplayName).ToList();
// }
//
//
// protected override void OnDestroy()
// {
// base.OnDestroy();
// if (this.MenuTree != null && this.MenuTree.Selection.SelectedValue != null)
// {
// var selectTarget = this.MenuTree.Selection.SelectedValue;
// if (selectTarget != null)
// {
// var selectType = selectTarget.GetType();
// if (_tabBases.TryGetValue(selectType, out GameFrameworkTabBase tab))
// {
// tab.Save();
// }
// }
// }
// }
//
// protected override OdinMenuTree BuildMenuTree()
// {
// var tree = new OdinMenuTree();
// foreach (var tabType in m_TabTypes)
// {
// DisplayNameAttribute displayNameAttribute = (DisplayNameAttribute)Attribute.GetCustomAttribute(tabType, typeof(DisplayNameAttribute));
// GameFrameworkTabBase instance = (GameFrameworkTabBase)Activator.CreateInstance(tabType);
// _tabBases.Add(tabType, instance);
// tree.Add(displayNameAttribute.DisplayName, instance);
// }
//
// tree.Selection.SelectionChanged += SelectionOnSelectionChanged;
// return tree;
// }
//
// private void SelectionOnSelectionChanged(SelectionChangedType obj)
// {
// var selectTarget = this.MenuTree.Selection.SelectedValue;
// if (selectTarget != null)
// {
// var selectType = selectTarget.GetType();
// if (_tabBases.TryGetValue(selectType, out GameFrameworkTabBase tab))
// {
// tab.Save();
// }
// }
// }
// }
// }