These Assets exist as a singular Asset in the database. Sort of just a collection of data to be used.
For example, I could have
public class ItemType : ScriptableObject {
int itemName;
int itemWeight;
}
Then create an Asset from ItemType…rename it to “Pistol” and set the itemName and itemWeight. My “Pistol” asset now carries around these standard values whenever I reference it from anywhere in the project.
The Asset can be copied and used if needed. Otherwise, any change to the Asset reference from any component will result in the Asset itself changing.
I can use this to store instances of items in an inventory system such as…
public class ItemInstance {
ItemType itemType;
public int itemID;
}
//inventory component attaches to any GameObject that will carry items
public class Inventory : MonoBehaviour {
List<ItemInstance> itemInstances = new List<ItemInstance>();
//Add items by creating new Iteminstances of ItemType with their own unique ID
}
In Unreal you can make an Asset out of any class if you learn how to use object factories:
This is the factory for my auto-save plugin’s main class, for example; where it creates new Blueprint assets out of the UClass I set as target object.
You can do this with any class child of UObject (this is Editor function, cannot be used in game code):
If you want to do this in blueprints you can make a custom struct which can contain any number of any types or array of types - and you can make it an array too.
I’m using a child-class of the core UObject class and just add my item variables to it. Then just create child-classes for all sub-class items (weapons, food, resources etc.) with additional parameters that class needs. With that structure you can easily plug it into any actor or just work with the data in UMG.
In content editor click Add New, Show all classes, choose “Object” and it’ll create the cpp and header for you. This way it’s just like in Unity, just make sure you know the C++ syntax & UE4 classes (FString instead of String etc.)