So as per the Burst documentation we can use static readonly arrays in Burst:
This works great and is an awesome way to have global arrays of static data for use in jobs and burst. I found that it breaks if I try to use other static readonly fields in the array construction though:
public static readonly int3 Up = new int3(0, 1, 0);
public static readonly int3 Down = new int3(0, -1, 0);
public static readonly int3 Left = new int3(-1, 0, 0);
public static readonly int3 Right = new int3(1, 0, 0);
public static readonly int3 Forward = new int3(0, 0, 1);
public static readonly int3 Back = new int3(0, 0, -1);
public static readonly int3[] CubeDirections = new int3[6]
{
Up,
Down,
Left,
Right,
Forward,
Back
};
If I embed the int3
s directly in the managed array then it works fine and is accessible from jobs/burst. But accessing the above array in Burst gives Burst error BC1022: Accessing a managed array is not supported
I’m guessing this is not a bug? Would it be possible to make this work in Burst?