Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ReferencePoint added list is empty in Android

Discussion in 'AR' started by ArmanUnity, Jun 24, 2019.

  1. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    22
    hi, i am adding a reference point at the position of camera by using arReferenceMaanger.AddReferencePoint(); , but the code is working perfectly with ios build and not with android build... something weird is happening, my code is below
    iam using ar foundation 2.1.0 ,ar core XR plugin 2.1.0 Arkit XR plugin 2.1.0

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.XR.ARFoundation;
    5. using UnityEngine.UI;
    6.  
    7. public class ReferenceDebugging : MonoBehaviour
    8. {
    9.     // Start is called before the first frame update
    10.     ARReferencePointManager aRReference;
    11.     ARCameraManager aRCamera;
    12.     public Text debugText;
    13.     void OnEnable()
    14.     {
    15.         //fetching compents from game object
    16.         aRCamera = Camera.main.gameObject.GetComponent<ARCameraManager>();
    17.         aRReference = GetComponent<ARReferencePointManager>();
    18.  
    19.         aRCamera.frameReceived += OnCameraFrameChanged;
    20.      
    21.     }
    22.  
    23.  
    24.     void OnCameraFrameChanged(ARCameraFrameEventArgs eventArgs)
    25.     {
    26.         debugText.text = "frame updated and Ref adding";
    27.         //Adding a refernece point once the Frame is updated
    28.         AddNewRefPoint();
    29.         aRCamera.frameReceived -= OnCameraFrameChanged;
    30.     }
    31.  
    32.     public void AddNewRefPoint()
    33.     {
    34.         //addding a reference point at camera's position
    35.         var refPoint = aRReference.AddReferencePoint(new Pose(Camera.main.transform.position, Quaternion.identity));
    36.         //Debug.Log("ref point status" + refPoint.pending);
    37.         debugText.text = " updated and Ref adding";
    38.         //subscribing refernce point changed event to get details about the added reference point
    39.         aRReference.referencePointsChanged += OnRefPointUpdated;
    40.     }
    41.  
    42.     void OnRefPointUpdated(ARReferencePointsChangedEventArgs eventArgs)
    43.     {
    44.  
    45.         foreach (var item in eventArgs.added)
    46.         {
    47.             //Do something with first reference point added
    48.             debugText.text = "new id is" + item.trackableId;
    49.             Debug.Log("ref added to the list");
    50.  
    51.             //unsubscribe after first ref point
    52.             aRReference.referencePointsChanged -= OnRefPointUpdated;
    53.             break;
    54.         }
    55.     }
    56.     private void OnDisable()
    57.     {
    58.         aRCamera.frameReceived -= OnCameraFrameChanged;
    59.         aRReference.referencePointsChanged -= OnRefPointUpdated;
    60.     }
    61.  
    62.  
    63.  
    64. }
    65.  
     
  2. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    22
    and if i add
    Code (CSharp):
    1. Debug.Log("ref point status" + refPoint.pending);
    just after add reference point code ,even if a null reference error occur, eventArgs.added list is updated and not empty any more and i am getting the trackableId,
    but iOS is working without need to make those errors when accessing pending state of the ref point .......why is it like that??
     
    Last edited: Jun 24, 2019
  3. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    22
  4. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    22
    any one experiencing this ,??? i updated xr package managers to preview3-2.1.0 but still not solved???anything on it @tdmowrer