Is there a way to trigger an action list asset after an inventory item is dragged from a container to the players inventory? It would be sort of like a combine event but with the inventory.
When an item is taken from a container, it is automatically placed in the player's inventory. At this time, OnContainerRemove is triggered, which you can use to access both the Container that was affected, and the item that was taken.
To see an example, place this code in a script named "InventoryEventTest", and attach to a GameObject in your scene:
using UnityEngine; using System.Collections; using AC; public class InventoryEventTest : MonoBehaviour {
Comments
When an item is taken from a container, it is automatically placed in the player's inventory. At this time, OnContainerRemove is triggered, which you can use to access both the Container that was affected, and the item that was taken.
To see an example, place this code in a script named "InventoryEventTest", and attach to a GameObject in your scene:
using UnityEngine;
using System.Collections;
using AC;
public class InventoryEventTest : MonoBehaviour
{
public ActionListAsset myActionListAsset;
private void OnEnable ()
{
EventManager.OnContainerRemove += OnContainerRemove;
}
private void OnDisable ()
{
EventManager.OnContainerRemove -= OnContainerRemove;
}
private void OnContainerRemove (Container container, ContainerItem containerItem)
{
Debug.Log ("Item " + containerItem.GetLinkedInventoryItem ().label + " was removed from " + container.name);
myActionListAsset.Interact ();
}
}
Then see the Console update when you remove items.
To trigger an ActionList asset, you just need to call its Interact function.