When restarting my Google Cardboard game with Application.LoadLevel(0); my Google Cardboard game starts upsidedown my my phone (fine in the editor but with error), and no input works on it (such as tap or pulling of the trigger).
When calling Application.LoadLevel(0); in the error it loads fine but gives this error:
Some objects were not cleaned up when closing the scene. (Did you spawn new Game Objects from OnDestroy?)
There's a bug in 0.4.10 when using Unity 4 Free that causes this. You can turn off the Native Distortion Correction option in the Inspector panel for CardboardMain. Alternatively, the bug is not there in 0.4.9, so you could use that version.
Related
I've been working in a project some weeks now in a Mixed Reality project using Unity and MRTK and I've found a strange behaviour when adding screen capture to the application. I'm using Unity 2019.4.26f1, and I haven't found any issues so far but after adding this line of code
ScreenCapture.CaptureScreenshot("test.png");
into a script, I've realised that when I press Play and go into Game mode, everything goes correctly (the game starts, the screenshot is taken). BUT when I stop it and try to go into Play mode again, Unity freezes. If I don't press Play again, Unity still works until it tries to compile scripts or some heavy task like that, when it freezes and can only be closed with the task manager.
If I remove that line, Unity goes back to normal.
This issue cannot be reproduced in Unity 2020.3 LTS. Does this happen when the remoting play or in Editor? According to Choosing a Unity version and XR plugin - Mixed Reality | Microsoft Docs, if you target to HoloLens 2, please upgrade to the recommended 2020.3 LTS version that is stated in the document.
In addition, ScreenCapture is a Unity built-in class and if there are any usage questions, you may find support from Unity forum.
I'm trying to use Unity in a Mac but the editor drops frames all the time. It shows it's rendering 330 fps but still feels laggy and dropping frames, also enemy movement is weird (I think it´s because it's dropping frames). This doesn't happen on windows (I tried both platforms). Before I used metal, and it rendered 35 - 45 fps dropping frames too. When I switched to OpenGL it went up to 330fps. I think the problem is not performance, but incompatibility of some kind. When I play the game built for Mac it works well.
Any idea of what could it be?
Statistics using OpenGL:
Statistics using Metal:
Make sure metal is enabled in the editor (not just when you export the game).
https://docs.unity3d.com/Manual/Metal.html
in old unity version metal was not enabled by default on mac and you had to use -force-gfx-metal and start the editor with terminal command line.
If it still not working I'm not sure what you can try... maybe try also to change your screen res.
Remember that Unity editor always use more resource, if the game is working fine when you export the game you can ignore the problem.
I've never encountered an issue like this before and everything I've tried to fix it has achieved nothing.
We have an app that uses Unity's built in Google Cardboard support that we have available on Android and iOS. The issue has never appeared on Android before, and also doesn't appear in a different project we have created using the same version of Unity (2018.1.1).
It appears the somehow when configuring the separate viewports for each eye it seems to get confused. The aspect ratio has been squished vertically and is stretching the displayed image. On top of this, the left and right eye appear to be facing in a cross eyed manor, where they should be facing more-or-less in the same direction. Here is an image representing the issue, with a line drawn around the current display area for each eye:
iOS cardboard display
This picture is of an iPhone 6, however this has been replicated on multiple devices including iPhone 8, iPhone X, and a few others that I cannot recall. Like I mentioned previously this has never happened on Android and also does not appear on iOS in a similarly setup project.
I have a suspicion that it has something to do with the way my Unity scenes are setup so I'll give a brief description of how things work at the moment.
Scene 1 - Menu scene
This is an entirely UI based scene (like most menus) and is setup in Portrait. It has a main camera that remains in standard mode (non-VR).
Scene 2 - Experience scene
This scene switches into Landscape view using code Screen.orientation = ScreenOrientation.Landscape. It has one camera in the scene that is initially in standard mode (non-VR) but can be toggled into VR using a button with this code:
public void SetStereoViewState(bool isActive) {
XRSettings.enabled = isActive;
#if !UNITY_EDITOR
// if device is a tablet (> 7" screen) always disable cardboard switch
// otherwise display only when cardboard mode is inactive
overlayCanvas.gameObject.SetActive(ScreenUtils.IsTabletDevice ? false : !isActive);
// needed to fix the aspect ratio when switching back to mono mode
vrCamera.ResetAspect();
#endif
Debug.Log("XRManager::SetStereoViewState | Enabling VR: " + isActive);
}
In a previous version of this app (running Unity 2017.2.0p2) this was never an issue, and is not an issue in a separate project also created in 2018.1.1.
What I've Tried So Far
camera.ResetAspect() - This was here to fix aspect issues when switching for VR to non-VR. I have enabled and disabled this when switching for every which way VR -> non-VR, non-VR -> VR etc. I have also delayed this until the next frame but without any change to the results
Enabling 'Cardboard' mode in the Landscape scene - The way I have always set my scene up in the past is to XRSettings.LoadDeviceByName({device_name}) at launch, in this case XRSettings.LoadDeviceByName("cardboard") but not enabling it with XRDevice.enabled = true until it is actually needed. | VR XRDevice.enabled = true - Non-VR XRDevice.enabled = false
Camera Setup
I don't think it's relevant since VR works perfectly fine on Android, but here is my somewhat default camera is setup:
Unity camera setup
I have considered setting up multiple cameras (left and right eye) but I can't see how this would make a difference as the aspect ratio is one of the issues.
If anyone has experienced a similar issue and has a fix, or has any advice in how to approach the situation in a different way that would be awesome.
NOTE:
Currently we are using Unity 2018.1.1 but I have also tried up to the most recent (at the time) 2018.1.5. A downgrade to 2017.x.x is not really possibly due to HttpWebRequests and Apple's somewhat frustrating IPv6 requirements which are broken until Unity 2018.x.x
FIXED
The issue is when loading 'cardboard' mode while in Portrait. Here is the code that I run at app launch to solve the issue:
private IEnumerator SetupCardboard() {
Screen.orientation = ScreenOrientation.Landscape;
XRSettings.LoadDeviceByName("cardboard");
yield return null;
Screen.orientation = ScreenOrientation.Portrait;
}
I am Using Unity 5.4.0f3 Personal(32bit), I developed demonstration application to display camera picture and three-dimensional AR which I acquired in Ovrvision Pro on Oculus Rift.
So I place prefabs, OVRCameraRig (view point camera) and OvrvisionSDK (Ovrvision imaging) from package ovrvision_unity5_includeOVR.unitypackage, and locate moving 3D objects. I intend an application that the 3D objects are moving in front of the video captured at Ovrvision.
Placing image
However, Ovrvision seems not to be recognized. The inspector of OvrvisionSDK says "Ovrvision status closed". And pressing [Play] button, "Ovrvision Open Error" occurs.
Ovrvision Open Error on Play
And when I connect Oculus Rift into the PC, the Unity editor crashes.
The version of Unity editor is 5.4.0f3, and the firmware version of Ovrvision Pro is 1.1, the latest.
I started developing with Unity only one and half month ago, and I may misunderstand the role of various packages and prefabs of Unity.
Best regards,
ichihara456
I am not sure if this is the solution to your problem, but I had similar issues with ovrvision (not using Unity, though). Turns out that in my case one USB port I was using was not a USB3 port (needs to be blue).
Might be worth a try...
Good luck!
I have converted my working project from Unity into Unity 5 and now the stereoscopic display doesnt work.
It seems like the stereoscopic effect doesnt work. The display is split in the middle, and the shader is applied, but it seems like there is only once camera. Like there are no eye cameras.
The weirdest thing is that everything works perfectly in the editor, but when I run it on device it seems like the cameras are disabled.
I went through and tried everything in the "known issues" in Cardboard SDK Release Notes, but nothing works.
Has anyone succesfully run a Cardboard game on Unity 5?
Yes, I have done. Mine isn't big one but has major things that can be said to be using UNITY features as well. I cant predict your problem as such but Answer to this post is certainly YES.
I don't think that anyone has posted this yet, but it appears that the SDK is currently broken in Unity 5.
From: Cardboard SDK Release Notes
Unity 5 rendering issues: As of Unity build 5.0.0f4, the following steps should be taken to fix or ameliorate any rendering issues, such as an all-black screen, flashing textures, or non-stereo views:
Enable the Development Build option in the Build dialog. This seems to fix various rendering glitches, like flashing textures.
The root cause of the rendering glitches is under analysis, with assistance from Unity.
I have also found that the app has rendering issues when it initially runs when you hit "Build and Run". Closing the app from the task switcher and restarting seems to resolve the issue.