`

UE4 Detecting VR Mode by Code

阅读更多

 

if you want add some platform depended code you can use this macros:

 

PLATFORM_MAC

PLATFORM_WINDOWS

PLATFORM_LINUX

PLATFORM_IOS

PLATFORM_ANDROID

WITH_EDITOR

 

or try to use this:

 

UGameplayStatics::GetPlatformName();

 

 

if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
{
   if (UEBuildConfiguration.bCompileSteamOSS == true)
   {
      DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
   }
   DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");
}
else if (Target.Platform == UnrealTargetPlatform.PS4)
{
   DynamicallyLoadedModuleNames.Add("OnlineSubsystemPS4");
}
else if (Target.Platform == UnrealTargetPlatform.XboxOne)
{
   DynamicallyLoadedModuleNames.Add("OnlineSubsystemLive");
}

 

 if u want to detecting VR Mode by code ,as below:

 

if ( GEngine->HMDDevice.IsValid() ) //check pointer is valid
{		
	if ( GEngine->HMDDevice->IsStereoEnabled() 
              && GEngine->HMDDevice->IsHeadTrackingAllowed() 
              || GEngine->HMDDevice->IsHMDConnected) //check stereo enabled
	{
	//do stereo stuff
	}
}
else
{
//do other non stereo stuff
}

 

 TIPS: MACRO #if OCULUS_RIFT_SUPPORTED_PLATFORMS does't work. i try it on Oculus VR.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics