Help with OnInventoryEquipItem

JohnG

Member
I have tried lots of different thing, Im just shooting in the dark atm because I just dont know how this works.

C#:
using System.Collections;
using System.Collections.Generic;
using Opsive.Shared.Events;
using Opsive.UltimateCharacterController.Inventory;
using Opsive.UltimateInventorySystem.Core;
using Opsive.UltimateInventorySystem.Core.DataStructures;
using UnityEngine;

public class InventoryListners : MonoBehaviour
{
    public GameObject m_Character;
    private void Start()
    {
        var inventory = m_Character.GetComponent<InventoryBase>();
        if (inventory == null) {
            return;
        }
     
        EventHandler.RegisterEvent<Item , int>(gameObject, "OnInventoryEquipItem", OnInventoryEquipItem);    
       // EventHandler.RegisterEvent<ItemInfo, ItemStack>(gameObject, EventNames.c_Equipper_OnChange, Equipper_OnChange);
    }
    private void Equipper_OnChange(ItemInfo itemIdentifier, ItemStack slotID)
    {
        Debug.Log("The inventory used " + itemIdentifier + ", " + slotID + " slot#.");
    }

    private void OnInventoryEquipItem(Item itemIdentifier, int slotID)
    {
        Debug.Log("The inventory used test " + itemIdentifier + ", " + slotID + " slot#.");
    }
 
    public void OnDestroy()
    {
        //EventHandler.UnregisterEvent<ItemInfo, ItemStack>(gameObject, EventNames.c_Equipper_OnChange, Equipper_OnChange);
        EventHandler.UnregisterEvent<Item , int>(gameObject, "OnInventoryEquipItem", OnInventoryEquipItem);    

    }
 

}

Am I maybe adding the code in the incorrect place?
Do I have to set something up on the character?

I have onimpact listner working but this seems to work differently.

I have added it to the character, and am also using UIS.
 
You already wrote a forum question about it, please do not make two post for the same question. We answer at least once a day during week days, so please be patient.
Like I mentioned in the other post, instead of gameObject you should be targeting m_Character.
 
You already wrote a forum question about it, please do not make two post for the same question. We answer at least once a day during week days, so please be patient.
Like I mentioned in the other post, instead of gameObject you should be targeting m_Character.
Yip sorry, the other one was supposed to be about c_Equipper_OnChange, (UIS documentation) and this one about OnInventoryEquipItem (ucc documentation), was not sure if I had to ask on each forum due to the different docs. Anyway, your explanation on the other thread help me understand both. thanks.
 
Top