Hello I am trying to update my plugin for Unreal Engine 5. I am able to use the plugin in my editor and it works fine but on packaging, I am getting an Error on ClassGeneratedBy.
Subsystem = GetWorld()->GetGameInstance()->GetSubsystem<UMortarResourceManager>();
if (Subsystem)
{
UClass* Class = Subsystem->GetClass();
UBlueprint* BP = Cast<UBlueprint>(Class->ClassGeneratedBy); //this line gives error
}
error C2039: ‘ClassGeneratedBy’: is not a member of ‘UClass’
I see that this variable is under WITH_EDITORONLY_DATA macro in Unreal Engine 5 but earlier it was not. What’s the reason and what is the alternative?
“What is the alternative” is much easier to answer if you were to describe what you actually want to do with this blueprint.
One option is to manually add the necessary data/class references as an explicit UPROPERTY() on the UObject in question and configure it the way you want it.
The blueprint is containing all the settings and I want to ensure that the subsystem I am picking is not the c++ one but instead the blueprint one. Here I am only checking if the Blueprint pointer is null or not. If null then I just return null otherwise I return Subsystem ptr;
It seems this solution only works if you are relying on choosing a blueprint in the editor and abstracting the c++ class. In my case, I have both the blueprint derived class and the c++ parent class. I want to differentiate the two and ClassGeneratedBy is perfect for that, but it is not available when packaged. Why and what would be the alternative?
One thing I found is that it looks like you can use the following to determine if a class has come from a blueprint. Class->HasAllClassFlags(EClassFlags::CLASS_CompiledFromBlueprint)