I have a class Item which contains a ScriptableObject ItemObject.

public class Item : MonoBehaviour
{
    public ItemObject itemObject;
}

public class ItemObject : ScriptableObject
{
    public string itemName;
}

I then have a **ResourceObject** ScriptableObject which inherits from **ItemObject** and a **Resource** class which inherits from **Item** and contains a **ResourceObject**
public class ResourceObject : ItemObject
{
    public int collectionDifficulty;    
}

public class Resource : Item
{
    public ResourceObject resourceObject;
}

I am needing to add the Resource to a list of Items

List<Item> inventory = new List<Item>();

I also need to be able to access the collectionDifficulty attribute of the resource.


However, when I create a new Resource GameObject, it requires both an ItemObject and a ResourceObject.

174056-help.png

How can I create a new Resource which only contains a ResourceObject yet is also an Item?

You could try this in Awake()

   ResourceObject resourceObject = ScriptableObject.CreateInstance<ResourceObject>();   

or Create a ScriptableObject prefab called ResourceObjectSO. Put it in a Resources folder and use

ResourceObject resourceObject = Resources.Load<ResourceObject>("ResourseObjectSO");

Then resourceObject will be set automatically and you can use

int someInt = resourceObject.collectionDifficulty;