Forum rules - please read before posting.

Inventory use item question

Hi all,
I have an inventory with 6 slots, and when you click on an inventory item it gives a description of the current selected item.

I'd like it so as soon as you open the menu the description of the current selected item is immediately there, but at the moment its empty and will only show the text if you click on it. Basically I'd like it to run the "use" interaction actionlist on whatever item is selected as soon as the menu turns on. Is that possible?

Comments

  • You can have a script hook into the OnMenuTurnOn custom event to listen out for your "Inventory" menu turning on, and then run the use interaction of the selected item:

    using UnityEngine;
    using AC;
    
    public class AutoUseSelectedItem : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            if (menu.title == "Inventory")
            {
                InvItem selectedItem = KickStarter.runtimeInventory.SelectedItem;
                if (selectedItem)
                {
                    selectedItem.RunUseInteraction ();
                }
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.