Device type & OS version: Android / iOS / Other Ex. iPhone 8+ on iOS 13
Host machine & OS version: Mac / Windows / Linux / Other Ex. Mac on Big Sur x.x
Issue Environment : Unity Remote / Unity Mock / On Device / Dev Portal
Xcode version:
ARDK version:
Unity version:
Description of the issue:
m stuck at step 4 at the start method where _scanManager.OnScanResult += ScanResultHandler; is showing an error at OnScanResult
This is my code
using Niantic.ARDK.AR;
using Niantic.ARDK.AR.Scanning;
using Niantic.ARDK.Extensions;
using Niantic.ARDK.Extensions.Scanning;
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
public class ScanningExampleManager : MonoBehaviour
{
[SerializeField]
[Tooltip(“The scene’s ARScanManager”)]
private ARScanManager _scanManager;
// …
[SerializeField]
private PointCloudVisualizer _pointCloudVisualizer;
void Start()
{
// Set default visualizer
_scanManager.SetVisualizer(_pointCloudVisualizer);
_scanManager.OnScanResult += ScanResultHandler;
}
public void ScanButtonPressed()
{
_scanManager.StartScanning();
}
public void StopButtonPressed()
{
_scanManager.StopScanning();
}
public void ProcessButtonPressed()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.ScanCompleted)
{
// Start processing scan
_scanManager.StartProcessing();
}
}
public Slider _progressBar;
private void Update()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.Processing)
{
_progressBar.gameObject.SetActive(true);
_progressBar.value = _scanManager.GetScanProgress();
}
else
{
_progressBar.gameObject.SetActive(false);
}
}
public void CancelProcessButtonPressed()
{
_scanManager.CancelProcessing();
}
private GameObject scannedObject;
private GameObject _scannedObjectPrefab;
public Transform _scannedObjectParent;
private void ScanResultHandler(TexturedMesh texturedMesh, IScanner.State state, Vector3 centerPosition)
{
if (texturedMesh != null)
{
if (scannedObject == null)
{
scannedObject = Instantiate(_scannedObjectPrefab, _scannedObjectParent);
}
Bounds meshBoundary = texturedMesh.mesh.bounds;
scannedObject.transform.localPosition = -1 * meshBoundary.center;
scannedObject.transform.localScale = Vector3.one / meshBoundary.extents.magnitude;
scannedObject.GetComponent<MeshFilter>().sharedMesh = texturedMesh.mesh;
if (texturedMesh.texture != null)
scannedObject.GetComponent<Renderer>().material.mainTexture = texturedMesh.texture;
}
}
Unfortunately we haven’t had the chance to update the documentation quite yet. The event you’re looking at has been renamed to OnScanProcessed and the individual parameters have been moved to the struct ScanProcessedArgs which is part of IScanner. I apologize for the confusion!
The event name is ScanProcessed, in the ARDK Example Scenes package you can find an example of how it’s used, look for the Scanning scene (which is basically the working reproduction of the scanning framework tutorial).
Hi Maverick,
Thanks for the advice.
Once implemented with ScanProcessed, the build error no longer occurs.
However, when it worked, an error occurred during scanning.
Below is a video of it in action.
using UnityEngine;
using UnityEngine.UI;
using Niantic.ARDK.AR;
using Niantic.ARDK.AR.Scanning;
using Niantic.ARDK.Extensions;
using Niantic.ARDK.Extensions.Scanning;
public class ScanningExampleManager : MonoBehaviour
{
[SerializeField]
private ARScanManager _scanManager;
[SerializeField]
private PointCloudVisualizer _pointCloudVisualizer;
[SerializeField]
private GameObject _scannedObjectPrefab;
[SerializeField]
private Transform _scannedObjectParent;
[SerializeField]
private Slider _progressBar;
private GameObject scannedObject;
// Start is called before the first frame update
void Start()
{
_scanManager.SetVisualizer(_pointCloudVisualizer);
_scanManager.ScanProcessed += ScanResultHandler;
}
// Update is called once per frame
void Update()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.Processing)
{
_progressBar.gameObject.SetActive(true);
_progressBar.value = _scanManager.GetScanProgress();
}
else
{
_progressBar.gameObject.SetActive(false);
}
}
public void ScanButtonPressed()
{
_scanManager.StartScanning();
}
public void StopButtonPressed()
{
_scanManager.StopScanning();
}
public void ProcessButtonPressed()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.ScanCompleted)
{
_scanManager.StartProcessing();
}
}
public void CancelProcessButtonPressed()
{
_scanManager.CancelProcessing();
}
public void SaveButtonPressed()
{
_scanManager.SaveCurrentScan();
}
private void ScanResultHandler(
IScanner.ScanProcessedArgs args)
{
var texturedMesh = args.TexturedMesh;
if (texturedMesh != null)
{
if (scannedObject == null)
{
scannedObject = Instantiate(_scannedObjectPrefab, _scannedObjectParent);
}
Bounds meshBoundary = texturedMesh.mesh.bounds;
scannedObject.transform.localPosition = -1 * meshBoundary.center;
scannedObject.transform.localScale = Vector3.one / meshBoundary.extents.magnitude;
scannedObject.GetComponent<MeshFilter>().sharedMesh = texturedMesh.mesh;
if (texturedMesh.texture != null)
{
scannedObject.GetComponent<Renderer>().material.mainTexture = texturedMesh.texture;
}
}
}
}
Thank you for taking the time to send your Unity package for me to look over. The error I encountered had to do with the PointCloudVisualizer lacking an Animation Curve, so I selected the slope curve (curve #2) and from there I was able to run the application, scan, and process it without incident. In order to assist you further, I will need to see the error message you’re encountering. You can find it by connecting your device to your development machine and building and running the application in debug mode. Any errors that occur should pop up in Android Studio or XCode depending on the platform you’re building for. Simply copy and paste the errors into a quote or code block and I will help you out from there.
Hi Maverick,
Thank you very much for your prompt response.
I followed your advice and after setting the Animation Curve, I built and ran it and got the same error.
There is text in the log that says Tap Scan button. This is the text I typed in; after tapping the Scan button, the screen froze a short time later.
The following error occurred.
2023-04-20 14:31:38.247513+0900 ScanningFramework[22494:8409885] Execution of the command buffer was aborted due to an error during execution. Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
2023-04-20 14:31:38.262506+0900 ScanningFramework[22494:8409886] Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (00000004:kIOGPUCommandBufferCallbackErrorSubmissionsIgnored)
For your information, my development environment and smartphone are as follows.
Unity Editor 2020.3.28f1
XCode 14.2
Lightship ARDK 2.5.1
iPhone 12 Pro (iOS 16.3.1)
I want to thank you for your patience! It looks like the issue coincidentally still has to do with the PointCloudVisualizer. It is at no fault of your own; however. To fix this, you need to open up PointCloudVisualizer.cs and modify the IsComputeBufferSupported() method on line 204 to always return false. Our development team is working on a fix for iOS devices but for now this is the fix you have to do to prevent that error from occurring.