Display different UMG UI according to the platform?

There is no passive method for that, you need to make stuff visible or load specific widget depending on platfrom name from here:

You can’t detect PIE in blueprints, you would need to make your own nodes (which is not that hard) in C++ using those functions in world instance:

Hi all,

Does anyone know how to display different UMG UI according to the platform(including the device simulation, e.g, setting Target Platform to Mobile and PIE the game on Windows.)? Just like Virtual Joystick.

Thank a lot.

Thanks for you reply, but I have another problem.

I wrote a BlueprintCallable function named ‘IsPlayInMobilePreview’ in my PlayerController and call it in my HUD blueprint with the Event BeginPlay.

My IsPlayInMobilePreview function’s implementation is just call another function in UWorld, like this:

return ()->IsPlayInMobilePreview();

But it always return false. I debugged it and found the real reason is:

FParse::Param(FCommandLine::Get(), TEXT(“simmobile”));

always get FALSE result.

I have tried launch the game with -simmobile commandline parameter and PIE with Mobile Preview, but get the same result, it’s always FALSE.

How do I solve this problem?

You not using in that preview right?

Yes, no .

I know this thread is old, but I’ll post the solution here for anyone who might need it, since checking the -simmobile argument is still used in UWorld::IsPlayInMobilePreview() and yet doesn’t work as of 2022.
You can use FSlateApplication::Get().IsFakingTouchEvents() to check for editor mobile preview and check if the return string from UGameplayStatics::GetPlatformName() equals to any mobile platform for standalone/packaged builds.

1 Like

Common UI has a more generic approach to platform traits, which are gameplay tags you can define in each platform to then enable/disable features as desired. Even without using this plugin, it’s a nice way of designing this system

1 Like