Inventool Action Menu
📋 InventoolActionMenu Class
📦 Fields
Access
Field
Type
Description
🔍 Properties
Access
Property
Type
Description
🧰 Methods
Access
Method
Returns
Description
InventoolActionMenu.Instance.Open(targetElement, myMenuOptions);InventoolActionMenu.Instance.Close();using Esper.Inventool.Items;
using Esper.Inventool.UI;
using System.Collections.Generic;
using UnityEngine;
public class ActionMenuCustomizer : MonoBehaviour
{
public Sprite myIcon;
private void Awake()
{
// Apply the customization on awake
ItemStack.actionMenuOptionsGetter = MyActionMenuOptionsGetter;
}
/// <summary>
/// Creates and returns the action menu options.
/// </summary>
/// <param name="itemStack">The item stack target to create the options for.</param>
/// <returns>A list of action menu options.</returns>
private List<ActionMenuOption> MyActionMenuOptionsGetter(ItemStack itemStack)
{
// Create a list that will contain the options
var options = ItemStack.GetDefaultActionMenuOptions(itemStack);
// Add an option
var myOption = new ActionMenuOption()
{
// Set the button text (smallcaps is generally used for styling purposes)
text = $"<smallcaps>My Option</smallcaps>",
// Set the button color
backgroundColor = new Color(0.3f, 0.3f, 0.3f),
// Set its order in the menu (lower numbers appear at the top)
sortingOrder = 0,
// Create an on-click action
action = () => Debug.Log("Do something"),
// Display a small icon beside the text
icon = myIcon
};
options.Add(myOption);
return options;
}
}using Esper.Inventool;
using Esper.Inventool.UI;
using System.Collections.Generic;
using UnityEngine;
public class ActionMenuCustomizer : MonoBehaviour
{
private void Awake()
{
// Apply the customization on awake
EquipmentSlot.actionMenuOptionsGetter = MyActionMenuOptionsGetter;
}
/// <summary>
/// Creates and returns the action menu options.
/// </summary>
/// <param name="slot">The equipment slot target to create the options for.</param>
/// <returns>A list of action menu options.</returns>
private List<ActionMenuOption> MyActionMenuOptionsGetter(EquipmentSlot slot)
{
// Create a list that will contain the options
var options = EquipmentSlot.GetDefaultActionMenuOptions(slot);
// Add an option
var myOption = new ActionMenuOption()
{
// Set the button text (smallcaps is generally used for styling purposes)
text = $"<smallcaps>My Option</smallcaps>",
// Set the button color
backgroundColor = new Color(0.3f, 0.3f, 0.3f),
// Set its order in the menu (lower numbers appear at the top)
sortingOrder = 0,
// Create an on-click action
action = () => Debug.Log("Do something")
};
options.Add(myOption);
return options;
}
}