arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

[Bug] ARFoundation ARMeshManager with MakeContentAppearAt

Open AdrienMgm opened this issue 5 years ago • 6 comments

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 :

  1. Create an AR project or start from the ARFoundation sample project
  2. Add the ARMeshManager as a child of ARSessionOrigin
  3. Use the MakeContentAppearAt() method provided by ARFoundation to scale & place the content where you want
  4. Build and launch the app on a device that supports LiDAR
  5. 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

AdrienMgm avatar Jan 12 '21 11:01 AdrienMgm

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.

AdrienMgm avatar Jan 19 '21 11:01 AdrienMgm

Hi @tdmowrer, any news about when you think the fix is going to be updated in a new ARFoundation package?

angecroft avatar Jan 22 '21 16:01 angecroft

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.

tdmowrer avatar Jan 23 '21 23:01 tdmowrer

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.

angecroft avatar Jan 26 '21 16:01 angecroft

Removing the Tests folder should be fine. If there are no other compilation errors, then it sounds like it worked correctly.

tdmowrer avatar Jan 26 '21 23:01 tdmowrer

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.

stale[bot] avatar Feb 03 '21 07:02 stale[bot]