2024-10-11 10:12:15 +08:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2024-10-28 03:42:42 +08:00
|
|
|
|
[MenuItem("配置/全局配置 &1")]
|
|
|
|
|
//[Shortcut("打开全局配置", KeyCode.F1)]
|
2024-10-11 10:12:15 +08:00
|
|
|
|
private static void OpenWindow()
|
|
|
|
|
{
|
|
|
|
|
var window = GetWindow<GlobalWindow>();
|
|
|
|
|
window.titleContent = new GUIContent("全局配置");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override OdinMenuTree BuildMenuTree()
|
|
|
|
|
{
|
|
|
|
|
var tree = new OdinMenuTree();
|
|
|
|
|
tree.Selection.SupportsMultiSelect = false;
|
|
|
|
|
|
2024-10-25 17:38:57 +08:00
|
|
|
|
GlobalSettings settings = AssetDatabase.LoadAssetAtPath<GlobalSettings>(PathConst.globalSettingsPath);
|
2024-10-11 10:12:15 +08:00
|
|
|
|
|
|
|
|
|
if (settings == null)
|
|
|
|
|
{
|
|
|
|
|
settings = ScriptableObject.CreateInstance<GlobalSettings>();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|