I’m looking to create a Scriptable Object for an item database, that way I can store the information my items require. (such as name, info etc.)
I’ve declared an Enum in my item script that allows me to declare what this item is used for, (combat, resource, Consumable).
My issue is I do not want items to have access to certain variables unless they are of the type required by it. Such as a Loaf of bread shouldn’t have access to AttackPower, if it is a consumable.
I originally had all my item requirements listed, but there are some I would only want to be available if the dependency is selected for a cleaner editor look mostly.
Note that the protected void Item Dependency was me fooling around with trying to get it to work with passing in variables into the If Statement. As you can tell from me being here it didn’t work.
Here is my code.
using UnityEngine;
[CreateAssetMenu(fileName = "Item", menuName = "Items/Create New Item")]
public class Items : ScriptableObject
{
//Basic Needed Info
new public string name;
//Special Attributes Combat
//Image
public Sprite icon = null;
//Item Characteristic
public enum ItemCharacteristic
{
Consumable,
Combat,
Resource,
};
public ItemCharacteristic itemCharacteristic;
protected virtual void ItemDependency()
{
if (itemCharacteristic == ItemCharacteristic.Combat)
{
}
}
}