Describe the bug in detail:
When attempting to create a jagged array from a method generic it will initialize a single dimensional array containing the types provided through the generic. Attempting to then assign another array within the root array will result in an error.
EG: T[][] temp = new T[3][]; will actually just create T[] not T[][]
Provide steps/code to reproduce the bug:
ArrayHelper.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class ArrayHelper
{
public static void JaggedArray<T>(ref T[][] jag, int rows, int cols) {
jag = new T[rows][];
for (int i = 0; i < rows; i++) {
jag[i] = new T[cols];
}
}
}
UdonScript.cs
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class UdonScript : UdonSharpBehaviour
{
private int[][] grid;
void Start() {
ArrayHelper.JaggedArray(ref grid, 7, 11);
}
}
We can verify that this is generating the outcome described above by replacing jag[i] = new T[cols]; with Debug.Log(jag.GetType()); and see the outcome is System.Int32[]
Expected behavior:
The expected result in the provided steps to reproduce is ArrayHelper.JaggedArray method would initialize all the secondary arrays in the passed ref. And jag = new T[rows][]; would initialize a jagged array, not a 1d array.
Extra Details;
This has only been tested and verified with the Client Simulator for unity bundled with creator companion. I have not yet built/tested in VRChat.
Describe the bug in detail: When attempting to create a jagged array from a method generic it will initialize a single dimensional array containing the types provided through the generic. Attempting to then assign another array within the root array will result in an error.
EG:
T[][] temp = new T[3][];
will actually just createT[]
notT[][]
Provide steps/code to reproduce the bug:
ArrayHelper.cs
UdonScript.cs
We can verify that this is generating the outcome described above by replacing
jag[i] = new T[cols];
withDebug.Log(jag.GetType());
and see the outcome isSystem.Int32[]
Expected behavior: The expected result in the provided steps to reproduce is
ArrayHelper.JaggedArray
method would initialize all the secondary arrays in the passed ref. Andjag = new T[rows][];
would initialize a jagged array, not a 1d array.Extra Details; This has only been tested and verified with the Client Simulator for unity bundled with creator companion. I have not yet built/tested in VRChat.