You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi, have you ever try to copy a List object? when I try it on Unity's c# script, it failed. When I debug the code, I found that the array's copy pass the case when the element type is Primitive.
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
But this cause the primitive element array would not get the memory allocated, after I add code
else
{
Array oArr = (Array)originalObject;
Array clonedArray = Array.CreateInstance(arrayType, oArr.Length);
Array.Copy(oArr, clonedArray, oArr.Length);
cloneObject = clonedArray;
}
it fixed.
The text was updated successfully, but these errors were encountered:
hi, have you ever try to copy a List object? when I try it on Unity's c# script, it failed. When I debug the code, I found that the array's copy pass the case when the element type is Primitive.
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
But this cause the primitive element array would not get the memory allocated, after I add code
else
{
Array oArr = (Array)originalObject;
Array clonedArray = Array.CreateInstance(arrayType, oArr.Length);
Array.Copy(oArr, clonedArray, oArr.Length);
cloneObject = clonedArray;
}
it fixed.
The text was updated successfully, but these errors were encountered: