FANDOM


This script demonstrates how clicks to an inventory menu can be overridden to give different behaviour to the default.

As an example, this script causes items to behave as though they're in "Context Sensitive" mode, regardless of the game's Interaction method.

To use it, create a Menu with an InventoryBox.  Set its Inventory box type field to Custom Script.  Paste the code below in a C# script named OverrideInventory, and place it on a new GameObject in the scene.

Make sure the names of your Menu and InventoryBox element match up with the names in the script.

using UnityEngine;
using System.Collections;
using AC;

public class OverrideInventory : MonoBehaviour
{
  
    private void OnEnable ()
    {
        EventManager.OnMenuElementClick += ElementClick;
    }


    private void OnDisable ()
    {
        EventManager.OnMenuElementClick -= ElementClick;
    }


    private void ElementClick (AC.Menu _menu, MenuElement _element, int _slot, int _buttonPressed)
    {
        if (_menu.title == "MyMenu" && _element.title == "MyInventoryBox")
        {
            MenuInventoryBox menuInventoryBox = (MenuInventoryBox) _element;
            if (_buttonPressed == 1)
            {
                menuInventoryBox.HandleDefaultClick (MouseState.SingleClick, _slot, AC_InteractionMethod.ContextSensitive);
            }
            else
            {
                menuInventoryBox.HandleDefaultClick (MouseState.RightClick, _slot, AC_InteractionMethod.ContextSensitive);
            }
        }
    }

}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.