using DG.Tweening.Plugins.Core.PathCore; using PlasticGui.WorkspaceWindow.Items; using Sirenix.OdinInspector; using Sirenix.OdinInspector.Editor; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; using Unity.VisualScripting; using UnityEditor; using UnityEditor.ShortcutManagement; using UnityEngine; namespace Ether { public class GlobalWindow : OdinMenuEditorWindow { [MenuItem("配置/全局配置")] [Shortcut("打开全局配置", KeyCode.F1)] private static void OpenWindow() { var window = GetWindow(); window.titleContent = new GUIContent("全局配置"); } protected override OdinMenuTree BuildMenuTree() { var tree = new OdinMenuTree(); tree.Selection.SupportsMultiSelect = false; GlobalSettings settings = AssetDatabase.LoadAssetAtPath(PathConst.globalSettingsPath); if (settings == null) { settings = ScriptableObject.CreateInstance(); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(PathConst.globalSettingsPath); AssetDatabase.CreateAsset(settings, assetPathAndName); // 最后刷新 AssetDatabase 来确保文件已经被正确保存 AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Selection.activeObject = settings; } EditorUtility.SetDirty(settings); tree.Add("全局设置", settings); return tree; } } }