Unreal Engine 5 Plugin Updation Issue

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.

Should be

Subsystem::StaticClass();

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;

Hello, How will this help? How will I make sure that the Subsystem is the blueprint one which is derived from C++ and not the C++ itself ?

You can check like this:

You can also use meta tags to not show your c++ class in blueprints… and make the UClass abstract if you are planning to use the BP deriving from it.

Anywhere you want a user to select a class from a list deriving from the c++ class you use the:

TSubclassOf<TheCSubsystemHere> Subsystem
1 Like

Thanks, for the help I will try :slight_smile:

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)