googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.09k forks source link

Needs API Updates for unity 5 #17

Closed frankcarey closed 9 years ago

frankcarey commented 9 years ago

I"m getting a bunch of errors when trying to import into unity 5, probably API changes?:

Examples:

Assets/Cardboard/Editor/CardboardEditor.cs(40,9): error CS0117: GUI' does not contain a definition forchanged'

Assets/Cardboard/Editor/CardboardEditor.cs(71,13): error CS0117: GUI' does not contain a definition forchanged'

smdol commented 9 years ago

I was not able to reproduce this -- it imported fine and ran in Unity 5 for me. Could you retry on an empty project?

nosmirck commented 9 years ago

I could import perfect, with no errors, the demo scene works fine in the editor, everything seems to work ok, but, when I compile and run in the device, it doesn't work... it's all black (some times white when moving the device) so I think the head tracking is working but not rendering correctly.

Is the plugin compatible with Unity5?

smdol commented 9 years ago

The all black screen is caused by the CardboardGUI script, which is somehow not compatible with Unity 5. Disable the script and the scene should work. On Mar 4, 2015 6:19 PM, "Luis Pulido" notifications@github.com wrote:

I could import perfect, with no errors, the demo scene works fine in the editor, everything seems to work ok, but, when I compile and run in the device, it doesn't work... it's all black (some times white when moving the device) so I think the head tracking is working but not rendering correctly.

Is the plugin compatible with Unity5?

— Reply to this email directly or view it on GitHub https://github.com/googlesamples/cardboard-unity/issues/17#issuecomment-77293942 .

nosmirck commented 9 years ago

@smdol perfect! it works :)

oatssss commented 9 years ago

I created a new project and imported the cardboard package and agreed to go ahead with the automatic api updates Unity prompted for on import. I then went to disable the scripts in the demo scene within CardboardGUI to find that they were already disabled. So I built and ran the scene on my phone (HTC One M7) and it worked, however, if I looked in the opposite direction of the cube, as nosmirck mentioned, the screen would flash white, or display a strange white radial gradient. If you would like to see a screen recording of the issue, I'd be happy to make one.

I am also getting this warning:

Assets/Cardboard/Scripts/SkyboxMesh.cs(69,12): warning CS0618: UnityEngine.Renderer.castShadows' is obsolete: Property castShadows has been deprecated. Use shadowCastingMode instead.'

If I choose not to go ahead with the automatic api updates that Unity prompts for on import of the package, these are the errors I get:

Assets/Cardboard/Scripts/CardboardEye.cs(68,23): error CS0619: UnityEngine.Component.camera' is obsolete: Property camera has been deprecated. Use GetComponent() instead. (UnityUpgradable)'

Assets/Cardboard/Scripts/CardboardEye.cs(68,30): error CS1061: Type UnityEngine.Component' does not contain a definition for rect' and no extension method rect' of type UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)

When I try to import the cardboard package into an existing project and add CardboardMain to an existing scene, no matter what I do, the screen on my phone always stays black - even when CardboardGUI is non-existent in the scene. What I'm going to try next is rebuilding my scene in a new, empty project since it's quite a simple scene. I had no issues with this package prior to Unity 5.

Thank you for all your work thus far.

jodybrewster commented 9 years ago

+1

smdol commented 9 years ago

More details about the Unity 5 compatibility issues have been found recently. The release notes here have been updated: https://developers.google.com/cardboard/unity/release-notes See the "Known Issues" section under v0.4.5.

The latest info is that making any calls to GUI class methods (e.g. GUI.Button, etc) is what causes the black screen. In the demo scene, removing CardboardGUI should disable all such calls, but in your own scene you might have some of these calls elsewhere in your code.

The build warnings and errors are from scripting changes in Unity 5. The Cardboard scripts need to be updated to Unity 5 in order to fix those. So far, I've been able to let the upgrade dialog do its thing without trouble.

The SkyboxMesh (which gives the warning) is broken for a different reason: Unity 5 skyboxes apparently no longer have 6 textures in them named _LeftTex, etc, so the script isn't finding them. That has to be fixed too.

smdol commented 9 years ago

BTW, I've seen the white flash when looking where the GUI would normally be, but I've never seen the white radial gradient thing. If you could capture that in a recording, post it here.

oatssss commented 9 years ago

Hey, good to hear you're working on it!! The flashing seems to just randomly put textures from the scene in front of the camera, I've also seen what looks to be part of the ground texture (the grid). Here's a video of it:

http://youtu.be/svERLby5gGs

Where the random flashing happens, the motion of the phone is just continuing the up and down pattern seen prior.

darkesco commented 9 years ago

Same issue here. I made a custom plane of a tile floor and added a material. The plane flashes in front of the camera at certain angles. I hope there is a fix soon :(

BorisBrock commented 9 years ago

Me too. For me it looks even worse than what can be seen in the video posted above. I'm also having several runtime exceptions (missing skybox textures). A fix for Unity 5 (personal) would be great :-)

smdol commented 9 years ago

@darkesco @VanKurt @oatssss Do your scenes have any GUI calls (GUI.Button, etc) or skybox? If so, can you disable or remove them and test to see if that makes things render better? More data will be helpful in tracking this down!

BorisBrock commented 9 years ago

Nope. No GUI, no skybox. Just some 3D models, a light and an instance of the CardboardMain prefab.

In the editor it looks fine, but on the android device things get messed up...

frankcarey commented 9 years ago

@VanKurt - (or others) maybe you can upload your projects to github if they're simple? Then we might be able to debug it together. Unity requires some configuration to be git-friendly. See http://stackoverflow.com/questions/21573405/how-to-prepare-a-unity-project-for-git

Cheers,

Frank Carey

On Thu, Mar 12, 2015 at 2:30 PM, VanKurt notifications@github.com wrote:

Nope. No GUI, no skybox. Just some 3D models, a light and an instance of the CardboardMain prefab.

Reply to this email directly or view it on GitHub https://github.com/googlesamples/cardboard-unity/issues/17#issuecomment-78558451 .

BorisBrock commented 9 years ago

I have quickly put together minimalistic example that shows the error. For simplicity I have uploaded it to Google Drive: https://drive.google.com/file/d/0B7EyW7gfSuJGNzFwSDBHR1V6NXc/view?usp=sharing (created on OS X)

smdol commented 9 years ago

Thanks @VanKurt for the test scene. I think I have a workaround for the strange popping artifacts, although it also disables the barrel distortion and the UI stuff between the two images.

1) On the Cardboard.SDK object, disable the following options: Native Distortion Correction Alignment Marker Settings Button 2) Edit Cardboard.cs, in function EndOfFrame, comment out the line: GL.InvalidateState();

You may see some weird stuff around the edges of the phone and between the eyes. That's because nothing in the SDK ever clears that area. But these areas should not be visible when the phone is in a Cardboard. The scene will look distorted in a Cardboard, just like it does in Unity 4 Free, because the distortion correction is turned off. Hopefully this will still allow you to experiment while the real fix is being figured out.

Near as I can tell, any time the Cardboard SDK calls functions on the GL class in Unity 5, things can go weird like this. The above workaround just bypasses all the GL calls currently in the SDK. Unity has been told, awaiting response.

Please confirm if this helps or not!

mnbattaglia commented 9 years ago

I was having the same black screen problem in my existing project, until I found I had an active script with a call to GUI.Label to draw current FPS. Removing that, skyboxes and CardboardGUI, seemed to work. OTOH, I'm experiencing some flickering problems in my HUD (using Unity new UI), random camera jumps and other lighting problems.

Can't wait for the fix! Unity 5 seems really powerful and complete and having the distortion correction available in free version is great!!!

Thanks for this really useful SDK!

Martín (from Argentina)

darkesco commented 9 years ago

So I went back to Unity 4 and now it works great but there are about 6 sceens behind my 2 main screens. It actually works fine in the goggles, but it's not very professional looking outside the viewer. I imagine all those screens are chewing up the CPU/GPU as well. Anyway, I'm a noob, I'll screw with it till it works.

smdol commented 9 years ago

Note on skyboxes: Unity 5 now has 3 skybox shaders: procedural, cubed, and 6-sided (the Unity 4 kind). The SkyboxMesh script only works with 6-sided skyboxes, as of v0.4.5.

smdol commented 9 years ago

Another skybox + Unity 5 update: I'm seeing that Unity 5's skybox shaders use the active projection matrix now during rendering. That means they should correctly handle the parallax caused by Cardboard's off-center projection, which was the whole reason for adding the SkyboxMesh script in the first place.

I recommend ripping out SkyboxMesh script altogether, and trying the scene without it. Make sure the sky seems very distant (farther than anything else in the scene) when viewed in stereo.

(I have to check lens flares to see if they are similarly treated. If so, the StereoLensFlare is not needed anymore either.)

smdol commented 9 years ago

@darkesco Add an extra Camera to the scene. Set its properties like so: clear flags = Solid Color background = Black (or whatever) culling mask = Nothing depth = -100

See if that takes care of the glop around the two eye viewports.

darkesco commented 9 years ago

@smdol where do I place the camera in the hierarchy? I tried different places and nothing seemed to help. Do I need to associate it as the background renderer or anything... or is that with the depth -100 does? Reminder, I'm using Unity 4 free until 5 becomes usable with cardboard. Thanks for your help BTW

darkesco commented 9 years ago

Adding the extra camera worked! I had to add it from the created tab. The component menu didn't seem to work. It's all good now. Thanks smdol!

smdol commented 9 years ago

@oatssss Turning on the Development Build option in the Build dialog makes the flashing textures problem go away for me. I've also removed all traces of GUI calls, and the SkyboxMesh script as well. Can you see if it helps you?

BorisBrock commented 9 years ago

Yeah, going into "Development Mode" solves all my issues, too. I wonder what this setting does? ;-) Could I upload an app to the Play Store that was built using this setting? I guess I'll have to do some research...

darkesco commented 9 years ago

"Development mode is not available on games acquired through the App Store / Play Store"

I'm sticking with Unity 4 for now. But it looks like Unity 4 free doesn't support reflections!?! I hope this is an oversight on my part.

BorisBrock commented 9 years ago

Are there any official news from the Cardboard or Unity developers? I'm really getting worried...

darkesco commented 9 years ago

@VanKurt I agree. I'm building anyway. Unity 4 looks like doo doo compared to Unity 5 IMO. I assume Google or Unity will get this resolved. Unreal Engine is great at VR but apk file size sucks and they don't appear to support cardboard. Unity has the market it appears; let's see if they act.

frankcarey commented 9 years ago

I don't think these are fundamental issues, so don't freak out. I'm going to try to get my own game working again today and will hopefully have a pull request / fork that proves useful.

Cheers,

Frank Carey

On Fri, Mar 20, 2015 at 5:14 AM, darkesco notifications@github.com wrote:

@VanKurt https://github.com/VanKurt I agree. I'm building anyway. Unity 4 looks like doo doo compared to Unity 5 IMO. I assume Google or Unity will get this resolved. Unreal Engine is great at VR but apk file size sucks and they don't appear to support cardboard. Unity has the market it appears; let's see if they act.

Reply to this email directly or view it on GitHub https://github.com/googlesamples/cardboard-unity/issues/17#issuecomment-83960903 .

darkesco commented 9 years ago

Thank you

smdol commented 9 years ago

@VanKurt Can you try an experiment? Put in the extra Camera like I suggested to @darkesco upthread, and remove SkyboxMesh, StereoLensFlare, and all CardboardGUI stuff from the project. Do not enable Development Build. Does this fix your rendering issues? (I've been noticing lately that I haven't had to enable this anymore.)

BorisBrock commented 9 years ago

@smdol I tried adding a dummy camera as suggested by you. Also I have none of the scripts/components active (e.g. SkyboxMesh, LensFlare etc.). Still the rendering issues remain. Only the Developer Build Mode fully solves the problems.

Another observation I made is that not all scenes are affected. I have one scene that works perfectly, and another that doesn't. Both use the same Cardboard camera system. Really strange...

darkesco commented 9 years ago

I'm still learning the subtleties of Unity. I'll try to remove GUIcalls. For the skybox, do I just remove skybox.cs or do I need to remove the component on all 4 cameras? I have MainCamera, left and right eye cameras, and the extra camera that clears the kaleidoscope issue.

smdol commented 9 years ago

@VanKurt That's what I'm seeing too, only now my scene not showing the problem was showing it before I made various changes to it. That means the bug, wherever it is hiding, is triggered under very specific conditions, which aren't clear yet. The experiment I had you try was a test for one possible condition (depth buffer not being properly cleared), but that doesn't seem to be it.

@darkesco The component to remove is SkyboxMesh, located on MainCamera alongside StereoController.

yorgsite commented 9 years ago

I foud some way to make the demo usable with unity5 but it requires some patches.

A/ From the Hierarchy editor :

1/ select 'Main Camera' and set his tag to 'Untagged' 2/ select 'CardboardMain' and set his tag to 'MainCamera' 3/ select 'Cube' and open 'Teleport' script

B/ In 'Teleport.cs'

1/ replace : head = Camera.main.GetComponent<StereoController>().Head; with head = GameObject.Find("Head").GetComponent<CardboardHead>();

2/ remove or comment these lines : CardboardGUI.IsGUIVisible = true; CardboardGUI.onGUICallback += this.OnGUI;

it removes the 'Reset' and 'Recenter' ui buttons (and it may be a cleanest way) but the rest works fine with android

smdol commented 9 years ago

New version 0.4.9 is out. It includes all the fixes we've discussed here: Unity 5 import errors, the kaleidoscope around the outside edges, etc. Note: Development mode may still be needed, but double check.

BorisBrock commented 9 years ago

Great news! Sadly the new version gives me a nasty error:

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/borisbrock/Assets/AndroidSDK/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/Unity.app/Contents/BuildTargetTools/AndroidPlayer/sdktools.jar" -

smdol commented 9 years ago

@VanKurt There are instructions for upgrading a project to the new version here:

https://developers.google.com/cardboard/unity/release-notes

BorisBrock commented 9 years ago

@smdol That's exactly what I did: remove the old Cardboard folder, then import the new package. Did I miss anything else?

smdol commented 9 years ago

Yes, but I think the Release Notes are not clear. Look down at the upgrade instructions for v0.4.5 too. There are some files to delete under Plugins. On Mar 27, 2015 12:21 AM, "VanKurt" notifications@github.com wrote:

@smdol https://github.com/smdol That's exactly what I did: remove the old Cardboard folder, then import the new package. Did I miss anything else?

— Reply to this email directly or view it on GitHub https://github.com/googlesamples/cardboard-unity/issues/17#issuecomment-86853073 .

smdol commented 9 years ago

@VanKurt The new release notes are changed to be clearer about upgrading. Hope that helps!

BorisBrock commented 9 years ago

@smdol Yes, it definitely will :-) But now there's another problem: the CardboardSDKForUnity.unitypackage seems not to importable. Unity gives me a

Fatal Error The file: 'MemoryStream' is corrupted. Remove it and launch Unity again! [Position out of bounds!]

Before I was just copying the Cardboard-folder from the zip archive to my Unity project. So I did not see that error. I already tried several times, re-downloaded the package, restarted Unity etc. BTW: I'm Using Unity 5.0 (main release) on OS X Yosemite.

UPDATE: I just realized the error occurs AFTER the import. So after restarting Unity, everything is fine. But sadly the flickering problem remains. :-(

smdol commented 9 years ago

I can honestly say I have never seen such an error! If you have not already tried, create a new project and import into that. I will try it too by downloading from Github myself. On Mar 27, 2015 1:05 AM, "VanKurt" notifications@github.com wrote:

@smdol https://github.com/smdol Yes, it definitely will :-) But now there's another problem: the CardboardSDKForUnity.unitypackage seems not to importable. Unity gives me a

Fatal Error The file: 'MemoryStream' is corrupted. Remove it and launch Unity again! [Position out of bounds!]

Before I was just copying the Cardboard-folder from the zip archive to my Unity project. So I did not see that error. I already tried several times, re-downloaded the package, restarted Unity etc. BTW: I'm Using Unity 5.0 (main release) on OS X Yosemite.

— Reply to this email directly or view it on GitHub https://github.com/googlesamples/cardboard-unity/issues/17#issuecomment-86864078 .

smdol commented 9 years ago

Also, for anyone else reading: Don't just copy the Cardboard/ directory into your project. It doesn't include the native libraries. Those are in the Plugins/ directory which is only in the unitypackage.

smdol commented 9 years ago

@VanKurt Just noticed your update. Good that it imports without error. Does the Development Build option fix the flicker?

BorisBrock commented 9 years ago

@smdol As with the previous version (0.4.5) of the Cardboard SDK, the flickering goes away when building in development mode.

darkesco commented 9 years ago

I saw an app released with the giant unity logo so I'm assuming that's unity 5. The full screen random texture flicker did not appear. I wonder how they got around that and were still able to release to the play store. Might try to gut the gui calls, but i have no idea to do that. I'll try searching for anything GUI and delete it. Will post back if I have any success.

smdol commented 9 years ago

It's a shot in the dark whether Development Build is needed, it seems. Currently I can build all of my test projects in Unity 5, and the only one that needs Development Build is the original version of the DemoScene (the one now in the Legacy subdirectory). The rest work fine without this option. It sure is hard to figure out what the problem is in this kind of situation...

BorisBrock commented 9 years ago

That's really strange. I would really love to publish my first (freeware!) VR-Game in the Play Store. So I keep praying to the flying spaghetti monster every night for a quick solution that works on EVERY Unity scene ;-)

999999333 commented 9 years ago

Hello, how to download previous version, during update i deleted it and now with a new version, unity 5 didnt work (blue screen)