Question by
Eric0x · Feb 12, 2020 at 12:23 PM ·
augmented realityhandheld
How to count AR point cloud number? (AR Foundation 3.0.1)
Hi all. I have been trying to count the number of all ar point cloud collected in the AR session
I've tried the following code. But arPointCloud keeps throwing error message: Object reference not set to an instance of an object
I would be so happy if anyone can help me. :eek:
Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
public class PointNumberCount : MonoBehaviour
{
ARSessionOrigin arSessionOrigin;
ARPointCloud arPointCloud;
int totalNumber;
List<Vector3> featurePoints = new List<Vector3>();
void Start()
{
arSessionOrigin = GetComponent<ARSessionOrigin>();
arPointCloud = arSessionOrigin.trackablesParent.GetComponentInChildren<ARPointCloud>();
}
void Update()
{
arPointCloud = arSessionOrigin.trackablesParent.GetComponentInChildren<ARPointCloud>();
featurePoints = new List<Vector3>(arPointCloud.positions);
totalNumber = featurePoints.Count;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Unity crashes when I click Play 1 Answer
Can I use unity UI image in the ARKIT ? 0 Answers
Vuforia, 2 images for single game object 0 Answers
ARFoundation: ARSessionOrigin.Raycast() no longer exists in Version 2.1.0?, 6 Answers
Can I trigger automatic flashlight events in my mobile AR experience? (Unity + Vuforia, iOS build) 0 Answers