Forum rules - please read before posting.

Animate removed invnentory item

So, you helped me animate an item that is added to the inventory (appears large in centre of screen then shrinks down into a position on screen - into inventory bag) in this thread.

https://adventurecreator.org/forum/discussion/11855/inventory-to-open-and-highlight-new-item-added/p1

Now I would like to do the same when removing an item from the inventory, can you help me adapt the script to do this?

Comments

  • The script covered in that thread hooks into the OnInventoryAdd event to set a RawImage's texture to that of the last-added item.

    The reverse would involve hooking into OnInventoryRemove to do set it to the last-removed item:

    public UnityEngine.UI.RawImage rawImage;
    
    private void OnEnable ()
    {
        AC.EventManager.OnInventoryAdd += OnInventoryAdd;
        AC.EventManager.OnInventoryRemove += OnInventoryRemove;
    }
    
    private void OnDisable ()
    {
        AC.EventManager.OnInventoryAdd -= OnInventoryAdd;
        AC.EventManager.OnInventoryRemove -= OnInventoryRemove;
    }
    
    private void OnInventoryAdd (AC.InvItem invItem, int amount)
    {
        rawImage.texture = invItem.tex;
    }
    
    private void OnInventoryRemove (AC.InvItem invItem, int amount)
    {
        rawImage.texture = invItem.tex;
    }
    
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.