I have successfully used TSubClassOf declarations before, however this time it is not working. Possibly because I need to access it to spawn my member property in the constructor. My current situation:
MyGameMode.h:
UPROPERTY(EditDefaultsOnly)
TSubclassOf<class UMapManager> MyMapManagerType = UMapManager::StaticClass();
UPROPERTY(BlueprintReadWrite)
class UMapManager* MyMapManager;
MyGameMode.cpp (in the constructor):
if (!MyMapManagerType)
{
UE_LOG(LogTemp, Error, TEXT("ERROR, no MapManager is selected by current game mode!"));
}
else
{
MyMapManager = NewObject<UMapManager>(this, *MyMapManagerType);
UE_LOG(LogTemp, Warning, TEXT("Created Map Manager"));
}
Picture of the BP_MyGameMode initializing the MapManager type:
Note that I have now attempted to put the default base class in, and yet in runtime, MyMapManagerType is always null and I get the error method. Is there some other way I should be doing this?
The MapManager is a class that the GameMode uses to generate the map.