IndieGame/client/Assets/Scripts/Editor/SceneSave/SceneSaveManagerEditor.cs

53 lines
1.4 KiB
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
namespace Ether
{
public class SceneSaveManagerEditor
{
public static ES3ReferenceMgr RefMgr
{
get { return (ES3ReferenceMgr)ES3ReferenceMgr.Current; }
}
[MenuItem("GameObject/场景/场景保存管理器", priority = 0)]
public static void CreateSceneSaveManager()
{
GameObject mgr = null;
if (RefMgr != null)
mgr = RefMgr.gameObject;
if (mgr == null)
mgr = new GameObject("SceneSaveManager");
if (mgr.GetComponent<ES3ReferenceMgr>() == null)
{
var refMgr = mgr.AddComponent<ES3ReferenceMgr>();
if (!Application.isPlaying && ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences)
refMgr.RefreshDependencies();
}
if (mgr.GetComponent<ES3AutoSaveMgr>() == null)
{
ES3AutoSaveMgr autoSaveMgr = mgr.AddComponent<ES3AutoSaveMgr>();
}
if (mgr.GetComponent<SceneSaveManager>() == null)
{
mgr.AddComponent<SceneSaveManager>();
}
Undo.RegisterCreatedObjectUndo(mgr, "Enabled Easy Save for Scene");
Selection.activeObject = mgr;
}
}
}