How to access Object Library which you create in content browser?

Is there a way to access the object library that you create in content browser to be accessed via code or blueprints?

I was able to find these two sources:

https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html#theassetregistryandobjectlibraries

Over there its suggesting to create the library dynamically by pointing it to a location.
I want to access the object library which I create in the content browser. Can you please guide me on how to do that?

I’d like to know this as well as it is completely undocumented how to use it as most types you can create in content browser, which is great shame, feature sitting there silent, that could be put to great use.

Hey Guys,

An hour ago, I was in the same position as you. And as so often, the solution turns out to be fairly simple once achieved:
The only thing we need to do is to write a C++ Function somewhere, which accepts a UObjectLibrary* and returns a UBlueprintGeneratedClass*.

In my Example I have a ObjectLibrary of the Type UConversationItem* in my Content Browser and I want to load those Objects in a Blueprint Function by the LibraryIndex and return them.


My ObjectLibrary:

First we need to create a Function within a C++ Class. I used my custom GameInstance to do so:

MagisterGameInstance.h

UFUNCTION(BlueprintCallable, Category = "ConversationDatabase")
		UBlueprintGeneratedClass* GetConversationItemFromDatabase(UObjectLibrary* ConversationLibrary, int ConversationID);

MagisterGameInstance.cpp

   UBlueprintGeneratedClass * UMagisterGameInstance::GetConversationItemFromDatabase(UObjectLibrary* ConversationLibrary, int ConversationID)
    {
    
    	TArray<UBlueprintGeneratedClass  *> ConversationList; 
    	ConversationLibrary->GetObjects<UBlueprintGeneratedClass>(ConversationList);

        //Make sure that ConversationID is in the Range of the Array, else return NULL
    	if (ConversationList.Num() > ConversationID)
    	{
    		return ConversationList[ConversationID];
    	}
    	else 
    		return nullptr;
    	
    }

As this is done now, the only thing left to do, is to call this function in our Blueprint and create an new Object of the returned Class:

Hope this helps!

1 Like