google-ar / arcore-unity-extensions

Google ARCore Extensions and Geospatial Creator for Unity's AR Foundation
Other
347 stars 97 forks source link

NullReferenceException in ARCoreHandleExtensions and ARCoreExtensions #189

Open pAnderDev opened 5 months ago

pAnderDev commented 5 months ago

I've been trying to use ARCloud anchors to use persistent anchors in my project. I imported the sample projects for persistant anchors but I have an issue that I can't figure out. I keep getting a NullReferenceException when referencing the Session.subsystem. Initially on startup I have a typecast error on line 213 of ARCoreExtensions image Then and object reference error at line 354 image Then in reference to the AR session subsystem and SessionHandle() image Last I have object reference errors that continue each frame as it is found in the Update method in the ARCoreExtensionsHandle image| This is happening in both my personal attempts to write a script to handle the hosting, resolving, and placement of the anchors as well as the sample project which I have not changed. I'm also using ARF 5 and have the correct script complication symbol ARCORE_USE_ARF_5. I'm developing for Android. If anyone has found how to fix this that would be greatly appreciated. I feel it is a deprecation that I'm missing and hasn't been updated yet but I am unsure.

Raidanin commented 4 months ago

I'm trying to use the geospatial creator, and I get the same issue when I run it in the editor.

Raidanin commented 4 months ago

I think I found a solution.

  1. Find Google.XR.ARCoreExtensions.asmdef file and fix the typing error (may optional)

       "name": "com.unity.xr.arfoundation",
        "expression": "[5.0,6.0)",
        "define": "ARCORE_USE_ARF_4"  >>  "define": "ARCORE_USE_ARF_5" 

https://github.com/google-ar/arcore-unity-extensions/issues/190

  1. Modify classes that are no longer used in ARCoreExtensions.cs

    private ARCoreSessionSubsystem _arCoreSubsystem; >> private XRSessionSubsystem _arCoreSubsystem;

    private ARCameraSubsystem _arCoreCameraSubsystem; >> private XRCameraSubsystem _arCoreCameraSubsystem;

And comment out the few configuration methods that are causing errors. Even after looking through the official documentation, I couldn't find a similar method. If you have a better opinion, please let me know.

After doing this, the built application worked normally. Hope this can help you. Thank you.