Forum rules - please read before posting.

Checking the active item in the inventory

Hello.
Sorry for my english.

Is there any way to check the active item in the inventory? Not selected, but active. I'm trying to make a mobile phone using the inventory box, where the inventory box displays the item as a photo. Photos are switched using shifts. I want the photo to be unselectable. But I need to know which photo is active at each time. So that when you press the call button, the corresponding conversationalist is called.

I tried to do this with cycles and pop-up variables. But I didn't find an opportunity to add new elements to the array. Therefore, my way of adding conversationalists to the phone turned out to be too cumbersome and not at all elegant.

Thanks.

Comments

  • Through scripting, you can hook into the OnMouseOverMenu custom event to record the last Inventory Item that was highlighted:

    using UnityEngine;
    using AC;
    
    public class RecordActiveItem : MonoBehaviour
    {
    
        void OnEnable () { EventManager.OnMouseOverMenu += OnMouseOverMenu; }
        void OnDisable () { EventManager.OnMouseOverMenu -= OnMouseOverMenu; }
    
        void OnMouseOverMenu (Menu _menu, MenuElement _element, int _slot)
        {
            if (_element is MenuInventoryBox)
            {
                MenuInventoryBox inventoryBox = _element as MenuInventoryBox;
                InvItem invItem = inventoryBox.GetItem (_slot);
                if (invItem != null)
                {
                    Debug.Log ("Over " + invItem.label);
                }
            }
        }
    
    }
    
  • Thank you. Now it works.

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.