Download

Does UE4 have anything like Unity AssetDatabase

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
}


Does anything like this exist in UE4?

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):

.h



UCLASS()
class SAVIORSETTINGS_API USaviorFactory : public UFactory {
	GENERATED_UCLASS_BODY()
protected:
	virtual bool IsMacroFactory() const { return false; }
public:
	virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
};


.cpp



USaviorFactory::USaviorFactory(const class FObjectInitializer& OBJ) : Super(OBJ) {
	bCreateNew = true;
	bEditAfterNew = true;
	**SupportedClass** = USavior::StaticClass();
}

UObject* USaviorFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) {
	check(Class->IsChildOf(USavior::StaticClass()));
	if (!FKismetEditorUtilities::CanCreateBlueprintOfClass(Class)) {return NULL;}
	return FKismetEditorUtilities::CreateBlueprint(Class,InParent,Name,BPTYPE_Const,UBlueprint::StaticClass(),UBlueprintGeneratedClass::StaticClass(),TEXT("AssetTypeActions"));
}


You can also use DataAsset blueprint which I think it’s easier to use because they do not require you to create any Editor custom module:

There’s also ObjectLibrary, even easier to use:

Awesome thanks… I think DataAsset is what I was looking for. I’m trying to get back into Unreal Engine and it’s been awhile.

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.)

EDIT: Got a tutorial for you … http://shootertutorial.com/2015/12/15/complete-skyrim-like-inventory-tutorial/