SHA256
Refactor Asset Loading
This commit is contained in:
9 files changed
+102
-162
No files matched your search
+53
-9
@@ -1,25 +1,68 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ADOFAIRenderer.Util;
|
||||
using MelonLoader;
|
||||
using O5Kit.Core;
|
||||
using TMPro;
|
||||
|
||||
namespace ADOFAIRenderer.UI;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class RendererUIManager : MonoBehaviour
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
internal static class ModAssets
|
||||
{
|
||||
public static void Load()
|
||||
{
|
||||
FontBundle = BundleLoader.GetBundle("fonts");
|
||||
NanumSquareNeoNormal = FontBundle.LoadAsset<TMP_FontAsset>("Assets/Fonts/NanumSquareNeoOTF-Bd SDF.asset");
|
||||
NanumSquareNeoBold = FontBundle.LoadAsset<TMP_FontAsset>("Assets/Fonts/NanumSquareNeoOTF-Hv SDF.asset");
|
||||
Melon<RenderMod>.Logger.Msg("Fonts loaded successfully.");
|
||||
|
||||
ShaderBundle = BundleLoader.GetBundle("shaders");
|
||||
ColorConversionShader = ShaderBundle.LoadAsset<ComputeShader>("ColorConversion");
|
||||
Melon<RenderMod>.Logger.Msg("Shader loaded successfully.");
|
||||
}
|
||||
|
||||
public static AssetBundle FontBundle = null!;
|
||||
public static AssetBundle ShaderBundle = null!;
|
||||
|
||||
public static TMP_FontAsset NanumSquareNeoNormal = null!;
|
||||
public static TMP_FontAsset NanumSquareNeoBold = null!;
|
||||
|
||||
public static ComputeShader ColorConversionShader = null!;
|
||||
}
|
||||
|
||||
internal sealed class RendererFontProvider : IFontProvider
|
||||
{
|
||||
private static readonly DefaultFontProvider DefaultFontProvider = new();
|
||||
private bool _disposed;
|
||||
|
||||
public TMP_FontAsset Regular => ModAssets.NanumSquareNeoNormal;
|
||||
public TMP_FontAsset Medium => ModAssets.NanumSquareNeoBold;
|
||||
public TMP_FontAsset Monospace => DefaultFontProvider.Monospace;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal class RendererUIManager : MonoBehaviour
|
||||
{
|
||||
private static RendererUIManager? _instance;
|
||||
public static RendererUIManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
var go = new GameObject("RendererUIManager");
|
||||
DontDestroyOnLoad(go);
|
||||
_instance = go.AddComponent<RendererUIManager>();
|
||||
}
|
||||
if (_instance != null) return _instance;
|
||||
|
||||
var go = new GameObject("RendererUIManager");
|
||||
DontDestroyOnLoad(go);
|
||||
|
||||
_instance = go.AddComponent<RendererUIManager>();
|
||||
return _instance;
|
||||
}
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public static O5Context Context => Instance._context;
|
||||
@@ -37,7 +80,8 @@ public class RendererUIManager : MonoBehaviour
|
||||
MiddleClickToDefault = true,
|
||||
SliderSensitivity = 1.0f
|
||||
},
|
||||
theme: O5Theme.Dark
|
||||
theme: O5Theme.Dark,
|
||||
fonts: new RendererFontProvider()
|
||||
);
|
||||
|
||||
_windowManager = O5WindowManager.Create(_context, transform, "RendererMod_Canvas");
|
||||
|
||||
Reference in new issue
Block a user