Forum rules - please read before posting.

Is it possible to have item interactions with menu elements? Hotspots within menus?

For example, I want to make it so that dragging an inventory item into a slot within a menu triggers an event. I can't seem to figure out how to set up a hotspot within a menu in which an item can interact with. Thanks in advance!

Comments

  • Can you elaborate on the situation? What kind of slot are you trying to drag an item onto?

    If your Menu is rendered with Unity UI, then you can add a custom script that listens for e.g. OnPointerDown, and does something (e.g. run an ActionList asset file) if a particular inventory item is selected:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using UnityEngine.EventSystems;// Required when using Event data.
    using AC;
    
    public class ExampleClass : MonoBehaviour, IPointerDownHandler
    {
    
        public int itemID;
        public ActionListAsset actionList;
    
        public void OnPointerDown (PointerEventData eventData)
        {
            if (KickStarter.runtimeInventory.SelectedItem != null && KickStarter.runtimeInventory.SelectedItem.id == itemID)
            {
                actionList.Interact ();
            }
        }
    
    }
    

    However, it's also possible to categorise inventory items so that different item types appear in different menus. You could, therefore, consider making the slot you want to drop the item on an inventory item as well, and have this display in a separate InventoryBox menu element, configured to show as text rather than an image.

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.