Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading existing project to new cardboard SDK #437

Open
lz7cjc opened this issue Oct 9, 2023 · 33 comments
Open

Upgrading existing project to new cardboard SDK #437

lz7cjc opened this issue Oct 9, 2023 · 33 comments
Labels
bug Something isn't working

Comments

@lz7cjc
Copy link

lz7cjc commented Oct 9, 2023

Hi
I am trying to upgrade to Unity 2022.3 so that I can use the new SDK for google cardboard.
My existing project is built in v2019

I have installed the latest SDK but not sure what to do with legacy code. Is there a How To guide for existing projects already using the older version and if not please can you confirm the steps?

I have tried creating a new project and copying over my project files from the original project but this results in 1000s of errors. Therefore I have just upgraded the project via Unity Hub and now need to retrofit the new version of the SDK.

These are a couple of the errors I am seeing
Prefab instance problem. Missing Prefab Asset: 'GvrReticlePointer (Missing Prefab with guid: 60270cf52a5e94998a5a335989159738)'
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Instance of Google.XR.Cardboard.XRLoader couldn't be created because there is no script with that name.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
We were unable to create an instance of the requested type Google.XR.Cardboard.XRLoader. Please make sure that all packages are updated to support this version of XR Plug-In Management. See the Unity documentation for XR Plug-In Management for information on resolving this issue.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Error creating instance of loader Cardboard XR Plugin for package Cardboard XR Plugin
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

I have installed Google Cardboard XR plugin 1.2.1.0

thanks for your help

@lz7cjc lz7cjc added the bug Something isn't working label Oct 9, 2023
@Mandelbrow
Copy link

Hi

Make a new project following the steps in the Quickstart guide first. Before upgrading existing projects. To see how it all works, and if you get the expected result, and performance.

There are also some common tips in this thread #140.

@lz7cjc
Copy link
Author

lz7cjc commented Oct 11, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Oct 13, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Oct 13, 2023 via email

@Mandelbrow
Copy link

Mandelbrow commented Oct 15, 2023

The Cardboard XR module only works in the build. Not in Editor Mode. You can use Conditional Compilation to don't load Google.XR.Cardboard.XRLoader when running in the Editor.

Enclose those parts in a #if !UNITY_EDITOR ... #endif block.

Then for example just use the inspector to turn the camera, to simulate a player looking around, when testing the app in the Editor.

@lz7cjc
Copy link
Author

lz7cjc commented Oct 15, 2023 via email

@Mandelbrow
Copy link

Maybe hit.distance can be used to determine if the interactable item is close enough to interact with?

@lz7cjc
Copy link
Author

lz7cjc commented Oct 15, 2023 via email

@Mandelbrow
Copy link

Mandelbrow commented Oct 16, 2023

@lz7cjc
Copy link
Author

lz7cjc commented Oct 16, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Oct 16, 2023 via email

@Mandelbrow
Copy link

@lz7cjc You have to read what Google found for you too.
The error means you are sending the command to an object which can't receive it.
Perhaps the ray is hitting other objects in the scene?
Debug.Log(hit.collider.name); could possibly tell if that's the case.

And, does this error really break the code?

@lz7cjc
Copy link
Author

lz7cjc commented Oct 16, 2023 via email

@arilow
Copy link

arilow commented Oct 26, 2023

Thanks @lz7cjc for reaching out to us. And sorry for the long delay!

Unfortunately there is no guide to migrate from GVR to the Cardboard XR Plugin. It is part of our backlog and will be prioritized among other tickets.

What is the state of the migration? If you share a copy of your project I will take a look to figure out what is missing.

Thanks!

@lz7cjc
Copy link
Author

lz7cjc commented Oct 27, 2023 via email

@arilow
Copy link

arilow commented Oct 27, 2023

Given that your project is currently using Unity 2019, you may try start the migration using Cardboard v1.16. That is the last Cardboard version that supported Unity 2019.4.

Once you make the migration work with Unity 2019.4, you can try upgrading the Unity version and use Cardboard v1.22.

About sharing you project, you can share a zip with your Unity project , a link to a Github repo or a drive link. That is up to you.

@andypoly
Copy link

andypoly commented Oct 27, 2023

Hi not being able to use with 2019 is a real problem for an internal project we have (2019 because of Unity big).
What changed after v1.16 that means Unity 2019 is no longer supported?
Edit: BTW on iOS you can actually use the latest plugin with 2019 & later no problem. On android I am not clear on the problem (own project crashes at startup)

@lz7cjc
Copy link
Author

lz7cjc commented Oct 30, 2023 via email

@arilow
Copy link

arilow commented Nov 2, 2023

@andypoly given that your comment is not related to the migration from GVR to the Cardboard SDK please create another issue with your concern so as to keep the topic of this conversation.

@lz7cjc As you said, given that your project is currently using GVR, I would expect that upgrading your project to Unity 2022 would cause many error messages.

My proposal is to follow these steps:

  • Preparation for migration: Try Running the Cardboard XR Plugin v1.16 sample on Unity 2019.4 by following the Quickstart.
    • This will allow you to be sure that you can run this version of the Cardboard XR Plugin and will prevent some possible errors when making the migration.
    • Note:* Take into account that the dependencies to add in Assets/Plugins/Android/mainTemplate.gradle are different for this version:
      implementation 'androidx.appcompat:appcompat:1.3.1'
      implementation 'com.google.android.gms:play-services-vision:20.1.3'
      implementation 'com.google.android.material:material:1.4.0'
      implementation 'com.google.protobuf:protobuf-javalite:3.19.4'
  • Migrate your project from using GVR to use Cardboard XR Plugin with Unity 2019.4.
    • For this you will have to use Cardboard v1.16. As you said, this would be a downgrade but it is only to make the migration easier for you, in the next step you will upgrade it again.
    • If you can get this done, then upgrading to 2022 should be easy.
  • Upgrade your project (Now integrated with Cardboard XR Plugin) to Unity 2022.3.
    • Now you will be able to use the last version of the Cardboard XR Plugin. Which at the moment is v1.22.

Feel free to ask any other question you might have about this topic.
Thanks!

@lz7cjc
Copy link
Author

lz7cjc commented Nov 2, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Nov 3, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Nov 11, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Nov 14, 2023 via email

@Mandelbrow
Copy link

@lz7cjc Do you really need Event Triggers for the UI elements? As the reticle sends messages to the GameObject the ray hits, there should be enough with scripts with corresponding method names to act on the incoming messages.

https://docs.unity3d.com/ScriptReference/GameObject.SendMessage.html
Description
Calls the method named methodName on every MonoBehaviour in this GameObject.

@lz7cjc
Copy link
Author

lz7cjc commented Nov 15, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Nov 21, 2023

Hi
I opened this ticket over 6 weeks ago (and not received a response from last post for 5 days). So for more than 6 weeks my project has been in limbo. Please can we get to a conclusion
To summarise where we are at:

  • In v2019 of Unity Editor I was using a hybrid of GVR and XR plugin Manager - this worked fine
  • I have to upgrade the editor so I can build to apk 31+ for android
  • Upgrade throws up loads of errors relating to GVR reticle pointer script - most seem to be around Daydream which I understand is no longer supported
  • When I remove the GVRreticlepointer script I am solely reliant on this Google Cardboard SDK

This results in the following issues which mean I can't launch an updated app which is massively overdue

  1. Restricting distance that reticle pointer interacts with objects - otherwise objects in the distance/hidden from view are active which causes confusion and makes my app unusable
  2. Need to use the event trigger component rather than in code and avoid having to use an interactive layer- failure to do this will require a massive rewrite of hundreds of objects and scripts
  3. If I have to use the interactive layer need documentation on how to use within a hierarchy. See example of how it only works in some cases, dependent on where in the hierarchy the objects sit (this works fine with the old set up)

NB
I have up until now been replying in email and looking at this thread is appears that none of the associated images have uploaded - so here are the key ones:
Reticle distance property - this restricts interaction with objects to those that "close" and deactivates anything in the distance
reticle distance

Interactive layer not working as object sits inside my player object
insideplayer
Interactive layer working as object sits outside my player object
hierarchyworks

How my legacy system is set up to work with reticle pointer and event trigger components + scripts - it is this same functionality i wish to replicate with the upgrade
eventtriggers
reticle distance

Please, can we get to the point where I have some solutions to implement so we can close this ticket.
thanks

@Mandelbrow
Copy link

Perhaps there are something going on with the event system. This post mention a custom Input Module for the Event system to respond to Gaze inputs #121 (comment)

@lz7cjc
Copy link
Author

lz7cjc commented Nov 22, 2023 via email

@lz7cjc
Copy link
Author

lz7cjc commented Nov 22, 2023 via email

@Mandelbrow
Copy link

If you are fine with a sprite for a basic reticle. To give a visual on when its active, in which direction the player is looking and when it is interacting with a button, or other game object. What is not covered in these two tutorials?

Gaze Events:
http://talesfromtherift.com/vr-gaze-input/

Reticle:
https://www.youtube.com/watch?v=LLKYbwNnKDg

@lz7cjc
Copy link
Author

lz7cjc commented Nov 23, 2023

apologies i thought i explained this in the previous post but will repeat here:

Quoting from article you reference


_"Lets add a crosshair to the above. There is the awesome YouTube video Oculus Rift DK2 – Unity Tutorial: Reticle that goes into full details about how to create a VR crosshair.

I’ve based mine on a couple of lines of code posted by cybereality in the Oculus forums. The key part is to maintain correct stereoscopic depth and move the crosshair to the same distance as the object being looked at, but crucially keep the crosshair looking the same size to the player. This is handled by these lines:_

void SetCrossHairAtDistance(float dist) { // Move the crosshair forward to the new distance Vector3 position = Crosshair.localPosition; Crosshair.localPosition = new Vector3 (position.x, position.y, dist); // But keep the crosshair the same perceptable size no matter the distance Crosshair.localScale = CrosshairOriginalScale * dist; }
"


I can't see any instruction as to where that code snippet should be placed

as for the second link you provide which was in this post, it is for Oculus, not cardboard
(the other link in the article is broken - New Unity UI + OVR Look-Based Input HOWTO)

I also mentioned that when I downloaded and imported the offered scripts on this post i got errors - which i included in my previous post
GazeInputModuleCrosshair.cs(51,32): error CS1061: 'GazeInputModule' does
not contain a definition for 'CurrentRaycast' and no accessible
extension method 'CurrentRaycast' accepting a first argument of type
'GazeInputModule' could be found (are you missing a using directive or
an assembly reference?)

I also pointed out that this is a post that has comments dating back to 2015 so I am wondering if this is relevant 8 years later when there is a completely different SDK ?

Based on these issues I haven't been able to make any progress with this article

Can I also ask about JoaoBorks contribution that i linked to above
This seemed to get closest to resolving my problem but I can't find the sample scenes and again it seems quite old with suggestions that it has been merged into the master release (but I can't find anything corresponding to this)

We seem to be going around in circles. Am I being unreasonable to expect support for an app that will published on Google Play using Google Cardboard SDK for Unity? Should I just accept that all the work I have done over the last few years should now be thrown in the bin?

Quite frankly I am starting to panic Google has effectively killed off my project so please excuse any frustration that is creeping into my responses. I am getting desperate

I still don't understand why there is no clear upgrade path from GVR to the Cardboard SDK that doesn't involve a complete rebuild or having to filter through loads of different suggestions, all of which so far are dead ends.

All I want to do is implement gaze and pick for objects within a certain distance. Isn't that the most basic of requirements for developing for Google Cardboard where there might be no physical button and no hand controllers?

Is there anyone else who can offer some help @arilow

@Mandelbrow
Copy link

Mandelbrow commented Nov 23, 2023

What make you believe a tutorial for placing, and scaling a sprite in the position av a Raycast hit.point isn't relevant after 8 years? The CameraPointer.cs in the HelloCardboard scene is already casting the ray.

@lz7cjc
Copy link
Author

lz7cjc commented Nov 23, 2023

the reason I assumed that was because Unity has changed significantly since 2015 so it would seem likely that this too has evolved. Obviously i was wrong so you can ignore that single comment as part of a far more ranging set of issues relating to that post. It does somewhat feel like you reply is missing the bigger picture

I have written in great detail about the problems I am experiencing. I am asking for help and you are not providing me with a workable solution - this is self defining since if i had a working solution i wouldn't be wasting your time or my own and i would be well on the way to publishing my app

You seem to think this is all very simple - so for someone without your experience, knowledge and big brain please can you provide the steps i need to take to upgrade from GVR to Google Cardboard SDK for Unity where i can restrict the working distance of the reticle pointer, using event triggers as components in the editor without the need to use an interact objective - i.e the standard way that GVR was previously implemented

then we can both move on with our lives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants