GoogleVR layout visible if stereo is off on iOS

Hi everybody,

I’m working on a GoogleVR project both on Android and iOS.
Only on iOS, when stereo rendering is off the VR layout (I mean the vertical line and the settings gear) still remain on the screen, but I’d like to have it disabled.

I found in [this post][1] a solution for Android on UE 4.12, but this issue occurs only on iOS and that solution seems not available on UE 4.13.2 which I’m working on, so it can’t help me.

Is there any workaround in order to hide or disable the VR layout when stereo is off (as happens on Android)?

Thanks for help.

UPDATE: this issue also occur in Unreal 4.14.3 with the Google VR plugin 1.0.1

UPDATE: this issue also occur in Unreal 4.14.3 with the Google VR plugin 1.0.1

Btw, how did you toggle on/off stereo rendering? My app crashes using Strereo On/Off

I am trying to locate where the problem is, do you use armv7 or arm64 for iOS dev?

EnableHMD also crashes for me T_T

I used EnableHMD blueprint node, but for me it worked also with stereo console commands.

I suggest you to open another post for this

We have this happening with 4.15.0 and iOS 10.2.1
using the Google VR plugin 1.2 (GVR NDK 1.10.0)

Using EnableHMD=False in Blueprint after level load.

On Android the interface goes away correctly but not in iOS.

After checking the UE source code, it seems that the just implement the Android hide-ui-layout logic.

.cpp

bool ::EnableStereo(bool stereo)
{
#if GOOGLEVRHMD_SUPPORTED_ANDROID_PLATFORMS
	// We will not allow stereo rendering to be disabled when using async reprojection
	if(bUseOffscreenFramebuffers && !stereo)
	{
		UE_LOG(LogHMD, Warning, TEXT("Attemp to disable stereo rendering when using async reprojection. This is not support so the operation will be ignored!"));
		return true;
	}
	AndroidThunkCpp_UiLayer_SetEnabled(stereo);
#endif

	bStereoEnabled = stereo;
	GEngine->bForceDisableFrameRateSmoothing = bStereoEnabled;
	return bStereoEnabled;
}

How did you get the interface disabled? If I use EnableHMD=False I don’t have a stereoscopic view.

We are using enableHMD=False to turn off stereo completely. I don’t think there is a way to remove the interface but keep it stereo unless you want to get into the source code yourself.

I need enabled HMD and I tried to set false UILayer in code .cpp but it doesn’t work.

I’ve find the way to hide the googlevr layout for iOS stereo off.

Currently(untile 4.15), according to the .cpp, the UE only add the GVROverlayView to show the GoogleVR ui-layout.

So when stereo off, we should hide the ui-layout ourself

NSArray* subviews = [[IOSAppDelegate GetDelegate].IOSView subviews];
for (UIView* childView in subviews)
{
	if ([childView isKindOfClass : [GVROverlayView class]] == YES)
	{
        // Get overlayView
		GVROverlayView* overlayView = (GVROverlayView*)childView;
        // stereo off/on
        [overlayView setHidden:YES/NO];
		break;
	}
}

Can you explain a bit further how to implement this? I can’t get it to work.

Yes, explain detailed, please!

Okay, I’ve got some!

I tryed many different methods to hide GVROverlay, but nothing worked.

So, I managed just do not even create it (ha-ha)

You can comment this line and no overlay will appear. It also affects startup screen, which telling the user to put the phone into cardboard. By the way this is exactly what I was looking for too.

So take a look at ::() method, find and comment the line “[[IOSAppDelegate GetDelegate].IOSView addSubview:OverlayView];”, which obviously just adds the overlay to screen. So if there are some calls to it, the app will not crash and etc.

See few lines of code here:

#elif GOOGLEVRHMD_SUPPORTED_IOS_PLATFORMS

		// We will use Unreal's PostProcessing Distortion for iOS
		bUseGVRApiDistortionCorrection = false;
		bIsInDaydreamMode = false;

		// Setup and show ui on iOS
		dispatch_async(dispatch_get_main_queue(), ^
		{
			OverlayViewDelegate = [[FOverlayViewDelegate alloc] init];
			OverlayView = [[GVROverlayView alloc] initWithFrame:[IOSAppDelegate GetDelegate].IOSView.bounds];
			OverlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
			OverlayView.delegate = OverlayViewDelegate;
		//	[[IOSAppDelegate GetDelegate].IOSView addSubview:OverlayView];
		});

I use UE 4.16.2

Update1:
It is a bad way to solve this problem, because application crashes, if you comment this line. It crashes only when you upload the app to TestFlight, downloar and run. When you directly install the application, it works fine.

Update2: atually I found the problem with crashing and it is not connected to disabling GVROverlay by commenting the line. So this method is actually okay to use. To make it work you need a source-built UE4. After you package a game for iOS once, you can replace *a file in GoogleVR/Binaries/IOS from source build to binary engine in the same place. That is what I have done for my project.

And one more thing! Doing this: [overlayView setHidden:YES/NO]; disables Google UI, so settings button and back arrow don’t respond, if you call [overlayView setHidden:YES]; they begin respond again when you turn it on, but image is still on screen in both situations. I think, that this image is not GVROverlayView class, or there are two items, one - as image, one - as triggers on this image. But I couldn’t find anything deeper in that case.

I tryed many different manipulations with [overlayView setHidden, setAlpha] and nothing works… And I couldn’t find any code reference to GVROverlayView, just nothing useful even in GVRSDK.framework archive. Does anybody know where can I read about this class and iOS methods, which can manipulate overlay, such as setHidden, setAlpha and etc? It seems that default iOS UIView methods don’t work here at all.

I will implement this feature without modify the UE’s source code.

In our app, user toggle the GoogleVR by click some button, when the button clicked, it will call the method EnableVRGoogleVR(true/false) function, detail as below

void UpdateVRView::EnableVRGoogleVR(bool bWillEnable)
{
#if PLATFORM_IOS
	UpdateIOSUILayout(bWillEnable);
	UHeadMountedDisplayFunctionLibrary::EnableHMD(bWillEnable);
	// blablabla
#endif
}


void AUpdateVRView::UpdateIOSUILayout(bool bWillEnable)
{
	NSArray* subviews = [[IOSAppDelegate GetDelegate].IOSView subviews];
	for (UIView* childView in subviews)
	{
		if ([childView isKindOfClass : [GVROverlayView class]] == YES)
		{
	    	// Get overlayView
	    	GVROverlayView* overlayView = (GVROverlayView*)childView;
	    	dispatch_async(dispatch_get_main_queue(), ^
			{
				[overlayView setHidden : !bWillEnable];
			});
	    	break;
	 	}
	}

}

I wish it will help you.

His thx for sharing your code im bite new to c++ . i have trying to implement ur code but keep getting error when trying to add the AUpdateVRView::UpdateIOSUILayout(bool bWillEnable) all variable inside are not detected . is there is any include for library that i need to add ?? thx

Hello , i need to ask you some questions and a favor. If i edit ProgramFiles\Epic Games\UE_4.17\Engine\Plugins\Runtime\GoogleVR\Source\Private.cpp to comment those lines, do i need to compile the plugin right?
Because i commented that line and i still have the google ui even if i set stereo off.
In the case that i need to compile could you give us some instructions? or in that case could you provide me with a compiled plugin for 4.17.2?

Thank you so much in advance.