Fix null component errors for custom multi menu

This commit is contained in:
Atony committed 2026-09-19 13:18:36 -05:00
1 parent 9f0cf11ba1
commit 0cb0527ddf
3 files changed
+41 -1

No files matched your search

+2 -1
View File
@@ -69,9 +69,10 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
customMenu.confirmButton = null!; // TODO: create/add confirm button
/*
var button = customMenu.confirmButton.GetComponent<PassiveButton>();
button.OnClick.RemoveAllListeners();
button.OnClick.AddListener((UnityAction)customMenu.OnCompleteSelection);
button.OnClick.AddListener((UnityAction)customMenu.OnCompleteSelection);*/
customMenu.activeColor = activeColor;
+8
View File
@@ -169,6 +169,14 @@ public abstract class CustomPhoneMenu : ICustomMenu
Component.Close();
}
/// <summary>
/// Forcibly closes the menu.
/// </summary>
public void ForceClose()
{
Component.ForceClose();
}
/// <summary>
/// Creates a <typeparamref name="TMenu"/>.
/// </summary>
+31
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Hud;
@@ -28,6 +29,36 @@ public class CustomPlayerMenu : CustomMultiSelectMenu<PlayerControl>
return Create<CustomPlayerMenu>();
}
/// <summary>
/// Creates a <see cref="CustomPlayerMenu"/>.
/// </summary>
/// <returns>New <see cref="CustomPlayerMenu"/> object.</returns>
/// <param name="activeColor">The <see cref="Color"/> to use when an entry is selected but not hovered over.</param>
/// <param name="hoverSelectSprite">The <see cref="Sprite"/> to use when an entry is hovered over while not selected.</param>
/// <param name="hoverSelectColor">The <see cref="Color"/> to use when an entry is hovered over while not selected.</param>
/// <param name="hoverDeselectSprite">The <see cref="Sprite"/> to use when an entry is hovered over while selected.</param>
/// <param name="hoverDeselectColor">The <see cref="Color"/> to use when an entry is hovered over while selected.</param>
/// <param name="onMouseOut">Function that can optionally be run when the mouse is moved outside a menu panel.</param>
/// <param name="onMouseOver">Function that can optionally be run when the mouse is moved over a menu panel.</param>
public static CustomPlayerMenu Create(
Color? activeColor,
LoadableAsset<Sprite>? hoverSelectSprite = null,
Color? hoverSelectColor = null,
LoadableAsset<Sprite>? hoverDeselectSprite = null,
Color? hoverDeselectColor = null,
PanelButtonOnMouse? onMouseOut = null,
PanelButtonOnMouse? onMouseOver = null)
{
return Create<CustomPlayerMenu>(
activeColor,
hoverSelectSprite,
hoverSelectColor,
hoverDeselectSprite,
hoverDeselectColor,
onMouseOut,
onMouseOver);
}
/// <summary>
/// Begins/opens the custom player menu.
/// </summary>