Need Help (Scriptable Object Inventory System) [Likely a Simple Fix]


Basically the way I have things set up currently will make the scriptable object pop up all the other options. I’m a 3D artist and not a programmer, but ive done my best over the last month to learn what I could. Its likely just a easy fix on how I coded the system (its obviously in very early stages). Basically I made different types for the system and I dont want nor need them all selected or active per different type.

Image (Top) is the current predicament
Image (Bottom) is what im trying to achieve with notations.

Here’s the foundation im building on :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum ItemType // ITEM PIPELINE FOUNDATION
{
    Weapon,
    Attachment,
    Equipment,
    Consumable,
    Default
}

public enum AttachmentType // ATTACHMENTS
{
    Laser,
    Flashlight,
    Grip,
    Slide,
    Barrel,
    Suppressor,
    Magazine,
    Stock,
}

public enum DefaultType // STATIC ITEMS
{
    Quest,
    Valuable
}

public enum ConsumableType // CONSUMABLES
{
    Food,
    Health,
    Ammunition
}

public enum WeaponType // WEAPONS
{
    Primary,
    Secondary,
    Melee,
    Throwable
}

public abstract class ItemObject : ScriptableObject
{
    public GameObject prefab;
    public ItemType type;
    public WeaponType weaponType;
    public ConsumableType consumableType;
    public AttachmentType attachmentType;
    public DefaultType defaultType;
    [TextArea(15, 20)]
    public string description;

}

Here’s one of the individual Scripts for type :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "New Health Item", menuName = "Inventory System/Items/Consumable/Health")]

public class Health : ItemObject
{
    public float healthEffect;
    public bool canStopBleeds;
    public void Awake()
    {
        type = ItemType.Consumable;
        consumableType = ConsumableType.Health;
    }
}

Thank you to anyone willing to help. I’m sure its a simple fix, I just haven’t been able to find it yet.

For this kinda reactive UI, generally you just write a custom editor. It sounds crazy-complicated but it’s not. Start with some simple tutorials and build confidence in how to lock out part of the display based on the state of one of the editable properties.

2 Likes

While the dropdown menu would be convenient, for now I just removed all the types besides the ItemType. That way in the inspector there isn’t pointless clutter and I get the same result for the most part. may not be as fancy but it works. Creating the object is the same way so it should be fine in the end. I think I was just wanting to overcomplicate something that should be simple. Thank you for responding though Kurt, I will definitely look into it and in the future if I decide my original idea is necessary I will definitely implement it. thank you again!

1 Like