Add Auto UI Initialization

This commit is contained in:
copecone committed 2026-10-05 14:28:18 +09:00
1 parent ec5b2f0ab6
commit 92a4654f14
3 files changed
+34 -14

No files matched your search

+28 -9
View File
@@ -1,4 +1,4 @@
using O5Kit.Core;
using O5Kit.Core;
namespace ADOFAIRenderer.UI;
@@ -6,15 +6,32 @@ using UnityEngine;
public class RendererUIManager : MonoBehaviour
{
public static RendererUIManager Instance { get; private set; } = null!;
private static RendererUIManager? _instance;
public static RendererUIManager Instance
{
get
{
if (_instance == null)
{
var go = new GameObject("RendererUIManager");
DontDestroyOnLoad(go);
_instance = go.AddComponent<RendererUIManager>();
}
return _instance;
}
private set => _instance = value;
}
public static O5Context Context = null!;
public O5WindowManager WindowManager = null!;
public static O5Context Context => Instance._context;
public O5WindowManager WindowManager => _windowManager;
private O5Context _context = null!;
private O5WindowManager _windowManager = null!;
private void Awake() {
Instance = this;
_instance = this;
Context = new O5Context(
_context = new O5Context(
config: new O5Config {
UIScale = 1.0f,
MiddleClickToDefault = true,
@@ -23,7 +40,7 @@ public class RendererUIManager : MonoBehaviour
theme: O5Theme.Dark
);
WindowManager = O5WindowManager.Create(Context, transform, "RendererMod_Canvas");
_windowManager = O5WindowManager.Create(_context, transform, "RendererMod_Canvas");
}
private void Update() {
@@ -33,7 +50,9 @@ public class RendererUIManager : MonoBehaviour
}
private void OnDestroy() {
WindowManager.Dispose();
Context.Dispose();
_windowManager.Dispose();
_context.Dispose();
if (_instance == this) _instance = null;
}
}