Forum rules - please read before posting.

Remove Inventory Image Appearing Late

Hi Chris,

So I have a set up where when an item is removed from the inventory, the RawImage appears in an animation being physically 'removed' from the inventory. However, the RawImage does not update straight away, and there is a delay until you see the item. I have two scripts associated with the raw image shown below, and a video showing the issue here, be great if you can help me with the issue! THANKS

VIDEO HERE: https://drive.google.com/file/d/10j-zy7GUMgypgvW0jWu8QDOYE4kpd8RC/view?usp=sharing

Scripts below:

INVENTORY REMOVE

using UnityEngine;

public class InventoryZoom : MonoBehaviour
{
    public UnityEngine.UI.RawImage rawImage;

    private void OnEnable() { AC.EventManager.OnInventoryAdd += OnInventoryAdd; }
    private void OnDisable() { AC.EventManager.OnInventoryAdd -= OnInventoryAdd; }

    private void OnInventoryAdd(AC.InvItem invItem, int amount)
    {
        rawImage.texture = invItem.tex;
        //trigger the animation here
    }

}

INVENTORY ZOOM REMOVE

using UnityEngine;

public class InventoryZoomRemove : MonoBehaviour
{
    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;
}
}

Comments

  • Where in the RemoveInventory asset is your "Inventory: Add or remove" Action to remove the item? Make sure that this runs before triggering the animation.

  • Genius! That did it! Thanks!

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.