[Bug] ARFoundation ARMeshManager with MakeContentAppearAt
Unity bug report case number 1305360
Description of the bug When using Meshing with an iPhone 12 Pro in our existing project, the meshes aren't correctly scaled or placed when we call MakeContentAppearAt() from the ARSessionOrigin for newly scanned environment. It works well with the ARPlaneManager though.
To Reproduce :
- Create an AR project or start from the ARFoundation sample project
- Add the ARMeshManager as a child of ARSessionOrigin
- Use the MakeContentAppearAt() method provided by ARFoundation to scale & place the content where you want
- Build and launch the app on a device that supports LiDAR
- See that the 3D reconstruction of your environment does not scale or place as it should be after a call from MakeContentAppearAt() (for the meshs that are instantiated when scaning your environment)
Expected behaviour : The new instantiated meshes should be scaled & placed correctly even after we use the MakeContentAppearAt() method, as the ARPlaneManager works.
Smartphone :
- Device : iPhone 12 Pro
- OS : iOS 14.2.1
- Unity Version : 2019.4.17f1
- ARFoundation version 4.1.1
- ARKit XRPlugin version 4.1.1
Hi, I was able to fix this issue by modifying ARMeshManager. However I can't fix it permanently because it is a script from a package and every time I reopen this project in Unity, it clears any modifications of this files.
So in the function GetSessionOrigin(), I think you need to replace return transform.parent.GetComponent<ARSessionOrigin>(); by return transform.GetComponentInParent<ARSessionOrigin>();
What happens is that when using MakeContentAppearAt() from ARSessionOrigin, every child of ARSessionOrigin is transferred under a new parent called Content Placement Offset. As ARMeshManager is forced to be a child of ARSessionOrigin, it is moved as well under this new gameObject. So now ARMeshManager can't find ARSessionOrigin because it isn't its direct parent.
Hi @tdmowrer, any news about when you think the fix is going to be updated in a new ARFoundation package?
Thank you for logging a bug and finding the solution. Your suggested fix looks right to me, though we still need to verify it on our end.
In the meantime, you can make this change on your end by embedding the package in your project. Instructions here: https://docs.unity3d.com/Manual/upm-api.html#Embed. There's also a forum thread where someone published a simple script to make it easy to embed any package.
Thank you for your help @tdmowrer
I've tried both solutions that you provided. The one from the Unity documentation, and the other from the forum thread. However when I try to embed the com.unity.xr.arfoundation package, I get the following errors :
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARFoundationTests.cs(1,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(1,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(2,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(2,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARFoundationTests.cs(5,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARFoundationTests.cs(5,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(6,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(6,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARFoundationTests.cs(8,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARFoundationTests.cs(8,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(9,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(9,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(8,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(8,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(8,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(8,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(37,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(37,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(65,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(65,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(90,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARLightEstimationDataTests.cs(90,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(59,10): error CS0246: The type or namespace name 'OneTimeSetUpAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(59,10): error CS0246: The type or namespace name 'OneTimeSetUp' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(11,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(11,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(118,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(118,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(41,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(41,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(124,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(124,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(72,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(72,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(131,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(131,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(103,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\MeshQueueTests.cs(103,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(138,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(138,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(145,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.unity.xr.arfoundation\Tests\Runtime\ARSessionTestFixture.cs(145,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
So I ended up deleting the Packages\com.unity.xr.arfoundation\Tests\ folder from the embedded package com.unity.xr.arfoundation in order to be able to continue to use my project.
I don't know if this was the right thing to do, or how could I have prevented the package to fail embedding at the first place? Because of that I have no idea if everything was copied into our project except for the Packages\com.unity.xr.arfoundation\Tests\ folder or not.
Removing the Tests folder should be fine. If there are no other compilation errors, then it sounds like it worked correctly.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.