ActionItem

For some reason if i create a pickupspawner with an actionitem and pick that item up and save. When i reload the actionitem is gone from my inventory. All other items are saved and stays in my inventory.
I havent done anything to the actionitem script. For some reason if I put out several health potions pick em up and save and reload the potions are gone but the red dot with the number is still in the slot.

if i try to use the empty action slot the item was saved in which is now empty i get a nullreferenceexception. So something is there but what?

using System;
using UnityEngine;

namespace GameDevTV.Inventories
{
    /// <summary>
    /// An inventory item that can be placed in the action bar and "Used".
    /// </summary>
    /// <remarks>
    /// This class should be used as a base. Subclasses must implement the `Use`
    /// method.
    /// </remarks>
    [CreateAssetMenu(menuName = ("GameDevTV/GameDevTV.UI.InventorySystem/Action Item"))]
    public class ActionItem : InventoryItem
    {
        // CONFIG DATA
        [Tooltip("Does an instance of this item get consumed every time it's used.")]
        [SerializeField] bool consumable = false;

        // PUBLIC

        /// <summary>
        /// Trigger the use of this item. Override to provide functionality.
        /// </summary>
        /// <param name="user">The character that is using this action.</param>
        public virtual void Use(GameObject user)
        {
            Debug.Log("Using action: " + this);
        }

        public bool isConsumable()
        {
            return consumable;
        }
    }
}

Check to make sure that the Health Potions (all Inventory Items) are in a directory named Resources

Also check to ensure that the Health Potion has a unique itemID.

Yeah forgott to put them in a resources folder, thnx!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms