Here’s the problem I have.
My framework plugin needs to be able to support both Unreal Engine 4 and Unreal Engine 5. However, one of my classes has a map of names to particle resources. Unreal 5 needs Niagara particles, whereas Unreal 4 would need Cascade particle resources (because Niagara, last I checked, doesn’t exist in Unreal 4, at least not in a finished state). [This is also the reason I used raw pointers instead of TObjectPtr<>.]
The current code looks like this:
/**
* Cascade particle resources for this skill.
*
* Cascade is a legacy feature and this only exists for such compatibility (and 4.27 compatibility).
* Please consider upgrading to Niagara for compatibility with future releases, as when Cascade is removed, this must also be removed.
*/
UPROPERTY(Category = "Skill|Cosmetic Settings (OPTIONAL)", EditDefaultsOnly)
TMap<FName, UParticleSystem*> CascadeParticleResources;
/**
* Niagara article resources for this skill.
*/
UPROPERTY(Category = "Skill|Cosmetic Settings (OPTIONAL)", EditDefaultsOnly)
TMap<FName, UNiagaraSystem*> NiagaraParticleResources;
The alternative WOULD look like this:
/**
* Particle resources for this skill.
*/
UPROPERTY(Category = "Skill|Cosmetic Settings (OPTIONAL)", EditDefaultsOnly)
#if ENGINE_MAJOR_VERSION 5
TMap<FName, UNiagaraSystem*> NiagaraParticleResources;
#else
TMap<FName, UParticleSystem*> CascadeParticleResources;
#endif
This is to allow developers to set up cosmetic resources for a skill, without having to do any programming to make those work, by using the framework’s Events system, or being able to display other resources (e.g. there’s a map for text resources for UI, such as skill descriptions, names, categories, etc.) on widgets.
However, obviously, this code wouldn’t compile. I can’t wrap UPROPERTYs in these either because that’s just how Unreal Header Tool is. And I also don’t want to have to copy-paste the ENTIRE framework just for Unreal 4 support, because if I did, updating it would be an absolute nightmare.
Any help would be appreciated. I really don’t know how I would do this.