Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug ArgumentOutOfRangeException with Initial setup

Discussion in 'Unity Analytics' started by Fangh, Jan 13, 2023.

  1. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    217
    This is my code :

    Code (CSharp):
    1.  
    2. public class AnalyticsManager : MonoBehaviour
    3. {
    4.     async void Start()
    5.     {
    6.         try
    7.         {
    8.             await UnityServices.InitializeAsync();
    9.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    10.         }
    11.         catch (ConsentCheckException e)
    12.         {
    13.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    14.             Debug.LogError($"User did not consent {e}", this);
    15.         }
    16.     }
    17. }
    18.  
    And when launching the app, this is what I get in the Cloud Diagnostic Crash & Exception

    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
    2. AnalyticsManager+<Start>d__1.MoveNext () (at <00000000000000000000000000000000>:0)
    upload_2023-1-13_10-9-34.png



    What I don't get is that I dont read the consentIdentifiers List, so I don't understand why it gives me an "Index is out of range" error.
     
  2. RandolfKlemola

    RandolfKlemola

    Unity Technologies

    Joined:
    May 1, 2020
    Posts:
    114
    Hi Fangh,

    Sorry for the delayed response. Are you still seeing this exception? Does this only occur when using your Oculus Quest? What version of the Unity Editor/Analytics package are you using? Are you using any other packages along with Analytics?

    Sorry for the 20 questions.

    Best,
    Randy