So I decided to load maps (or levels) and game modes directly from assets folder.
I had no problems with levels, they are perfectly being loaded while PIE and grabbed by level controller (my magic automatic class for server).
But game modes ain't found by UObjectLibrary. Literally. I double checked everything.
So, declarations (somewhere in .h):
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Level Controller")
class UObjectLibrary * gameModesLibrary;
// ... Constructor
// ... BeginPlay
gameModesLibrary = UObjectLibrary::CreateLibrary(ARayGameModeBase::StaticClass(), true, GIsEditor);
if (gameModesLibrary->LoadAssetDataFromPaths(gameModesPaths) == 0)
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "No assets derived from ARayGameModeBase found");
if (gameModesLibrary->LoadAssetsFromAssetData() == 0)
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "No assets derived from ARayGameModeBase loaded");
For those who lost in this mess: first I declared paths where to search for classes (objects) derived from ARayGameModeBase; then called CreateLibrary with support for Blueprint classes (there are some blueprint classes derived from this C++ one); finally I attempted to check if number of found assets returned by LoadAssetDataFromPaths isn't equal 0.
LoadAssetsFromAssetData returns 0 no matter what, means it found nothing.
Absolutely the same algorithm is used to load maps. Maps begin loaded just fine, I can travel between them using their asset names.
I checked everything:
Paths - OK;
Base class and game modes in folder have this class as parent - OK;
Truly scientific "let's make this like that and check if it works" in many variations - OK;
What am'I doing wrong? Even game modes should be spawned classes in content, ain't they?
Jul 09 '17 at 06:25 PM
in C++ Programming