Code like this:
USTRUCT(BlueprintType)
template< class T >
struct MYMODULE_API FStruct_UserWidgetClassIndex_Platform
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”, DisplayName = “PCStyle”)
TSubclassOf< T > PCClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”, DisplayName = “ConsoleStyle”)
TSubclassOf< T > ConsoleClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”, DisplayName = “PhoneStyle”)
TSubclassOf< T > PhoneClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”, DisplayName = “VRStyle”)
TSubclassOf< T > VRClass;TSubclassOf< T > GetWidgetClassByPlatform()
{
#if (defined( PLATFORM_WINDOWS ) && PLATFORM_WINDOWS) ||(defined( PLATFORM_MAC ) && PLATFORM_MAC) ||(defined( PLATFORM_HTML5 ) && PLATFORM_HTML5)
return PCClass;
#endif
#if (defined( PLATFORM_PS4 ) && PLATFORM_PS4) ||(defined( PLATFORM_SWITCH ) && PLATFORM_SWITCH) ||(defined( PLATFORM_XBOXONE ) && PLATFORM_XBOXONE)
return ConsoleClass;
#endif
#if (defined( PLATFORM_ANDROID ) && PLATFORM_ANDROID) || (defined( PLATFORM_IOS ) && PLATFORM_IOS)
return PhoneClass;
#endif
return PCClass;
}
};
UCLASS(BlueprintType)
class MYMODULE_API UMyGameInstance :public UGameInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”)
FStruct_UserWidgetClassIndex_Platform<UUserWidget_Message> UIStyle_Message;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”)
FStruct_UserWidgetClassIndex_Platform<UUserWidget_PlayerLogin> UIStyle_PlayerLogin;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “UI|Style”)
FStruct_UserWidgetClassIndex_Platform<UUserWidget_PlayerRegister> UIStyle_PlayerRegister;
}
I need make a template struct to pakage some userwidget classes and let it can be edit in blueprint. So this value which in gameinstance had diffrent cpp class.
I want to make a template struct but I cant . have any way to do it?