Using C# and the Burst compiler
The Burst compiler in Unity is an advanced compiler technology that can be used to convert a subset of .NET code into highly optimized native code for Unity games. It should be noted that it is not a general-purpose compiler, but a compiler designed for Unity to make Unity games run faster.
Burst works on a subset of C# called HPC#, so let's explore this subset of C# next.
High-Performance C# (HPC#)
HPC# is a subset of C#. The standard C# language uses the concepts of "objects on the heap" and uses the garbage collector to reclaim unused memory automatically. So, as developers, we cannot control how the data is allocated in memory. On the other hand, HPC# doesn't support reference types, namely, classes, to avoid allocation in the heap and disable the garbage collector. In addition to these, some functions, such as try-catch-finally
, are not supported in HPC# as well.
To summarize, we can use the following types in HPC...