mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
error check and more verbose error log
This commit is contained in:
1 parent
d9fb89d86b
commit
dcf6221671
1 file changed
+8
-1
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
@@ -12,10 +13,16 @@ public static class CustomButtonManager
|
||||
{
|
||||
if (!typeof(CustomActionButton).IsAssignableFrom(buttonType))
|
||||
{
|
||||
Logger<MiraApiPlugin>.Error($"{buttonType?.Name} does not inherit from CustomActionButton.");
|
||||
return;
|
||||
}
|
||||
|
||||
var button = (CustomActionButton)Activator.CreateInstance(buttonType);
|
||||
if (Activator.CreateInstance(buttonType) is not CustomActionButton button)
|
||||
{
|
||||
Logger<MiraApiPlugin>.Error($"Failed to create button from {buttonType.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
CustomButtons.Add(button);
|
||||
typeof(CustomButtonSingleton<>).MakeGenericType(buttonType)
|
||||
.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)!
|
||||
|
||||
Reference in new issue
Block a user