Where can I use Multidimensional Array in Unity?

Hey I am new to the Unity and I am currently learning C# for game development and my question is Where can I use MultiDimensional Array in Unity

Not sure what this question is about exactly. You “can” use them anywhere in your code. However be aware that Unity can not serialize multidimensional arrays. So they can not be displayed in the inspector as a result. So you can only use them in code. Unity does use ordinary C# so there’s not really anything special when it comes to the language. Unity does have some quirks when it comes to UnityEngine.Object and derived types due to the managed - native duality of those objects. Though C# is still just normal C#

Note that in almost all cases you don’t really want to use multidimensional arrays as they are a bit clunky to work with and in the end they are just flattened one dimensional arrays under the hood with some additional language support and range checks which actually make them quite slow in tight loops. In most cases it’s easier and faster to just use a flattened one-dimensional array and calculate the offset yourself.

Since you didn’t mentioned any specific application, I don’t really know where to go from here…

1 Like