SHA256
Initial Commit
This commit is contained in:
commit
44a22ae103
19 files changed
+772
No files matched your search
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Util
|
||||
{
|
||||
public static class BundleLoader
|
||||
{
|
||||
private static string BundlePlatform;
|
||||
private static readonly Assembly? ExecutingAssembly;
|
||||
|
||||
static BundleLoader()
|
||||
{
|
||||
BundlePlatform = Application.platform switch
|
||||
{
|
||||
RuntimePlatform.WindowsPlayer => "Win64",
|
||||
RuntimePlatform.OSXPlayer => "OSX",
|
||||
_ => "Linux"
|
||||
};
|
||||
ExecutingAssembly = Assembly.GetExecutingAssembly();
|
||||
}
|
||||
|
||||
public static AssetBundle GetBundle(string resourcePath)
|
||||
{
|
||||
if (ExecutingAssembly != null)
|
||||
{
|
||||
var bundlePath = $"ADOFAIRenderer.Bundle.{BundlePlatform}.{resourcePath}";
|
||||
using var resourceStream = ExecutingAssembly.GetManifestResourceStream(bundlePath);
|
||||
if (resourceStream != null)
|
||||
{
|
||||
return AssetBundle.LoadFromStream(resourceStream);
|
||||
}
|
||||
|
||||
Melon<RenderMod>.Logger.Error($"DLL에서 번들 리소스를 찾을 수 없습니다.\n{bundlePath}");
|
||||
throw new MissingManifestResourceException("Could not find bundle resource in DLL.");
|
||||
}
|
||||
|
||||
Melon<RenderMod>.Logger.Error("실행 어셈블리가 제대로 설정되지 않았습니다.");
|
||||
throw new InvalidOperationException("ExecutingAssembly has not been set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user