Describe the bug
ARPointCloudManager.Append() method throws ArgumentException in the Editor.
To Reproduce
Call the ReproduceBug() method in the Editor.
using System.Reflection;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.XR.ARFoundation;
public static class ARPointCloudManagerBug {
public static void ReproduceBug() {
var array1 = new NativeArray<int>(0, Allocator.Temp);
var array2 = new NativeArray<int>(new int[42], Allocator.Temp);
var method = typeof(ARPointCloudManager).GetMethod("Append", BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method);
var genericMethod = method.MakeGenericMethod(typeof(int));
try {
genericMethod.Invoke(null, new object[] {array1, array2, array2.Length, Allocator.Temp});
} catch (ArgumentException e) {
Debug.LogError(e);
} finally {
array1.Dispose();
array2.Dispose();
}
}
}
Reproducible with
Unity Editor [2019.2, 2021.2]
AR Foundation [3.0.1, 5.0.0-pre.8]
Proposed solution
Add the currentArray.Length parameter to this line:
NativeArray<T>.Copy(currentArray, dstArray, currentArray.Length);
Describe the bug ARPointCloudManager.Append() method throws ArgumentException in the Editor.
To Reproduce Call the ReproduceBug() method in the Editor.
Reproducible with Unity Editor [2019.2, 2021.2] AR Foundation [3.0.1, 5.0.0-pre.8]
Proposed solution Add the currentArray.Length parameter to this line:
NativeArray<T>.Copy(currentArray, dstArray, currentArray.Length);