IDisposable is becoming more and more prevalent in Unity. Previously, it was typically only used for I/O types like
FileStream. Now it’s used for in-memory types like
NativeArray<T> to avoid the garbage collector. Needing to call
Dispose manually means we’re explicitly managing memory, just like we’d do in lower-level languages like C++. That comes with some challenges, especially with shared ownership, which we’ll deal with today.
Posts Tagged burst
Unity provides exactly one collection:
NativeArray<T>. Compared to managed arrays in C#, these must be one-dimensional. So today we’re building a two-dimensional version of it:
NativeArray<T>. We’ll add this to the NativeCollections GitHub repository for easy inclusion into any project. Read on to learn more about the collection!
Job structs can’t contain managed types like
class instances, or delegates. This is currently a pain as a lot of the Unity API relies on these and so we’re forced to deal with them. Today we’ll talk about how we can use managed types in our jobs to bridge the gap.
A couple years ago, I wrote an article showing how to empower game designers with the ability to write simple formulas like
PlayerLevel*100+100. These are much more useful than just constants and don’t require any of the complexity of a real programming language. Today we’ll bring it into the Burst-compatible world and also improve its ability to handle more complex formulas.
Many algorithms get used over and over: searching, sorting, filtering, etc. C# makes these available with LINQ and functions like
Array.Sort, but these can’t be compiled by Burst because interfaces and delegates aren’t supported. So how do we implement these generic algorithms to avoid re-writing them over and over? Today we’ll explore one technique to solve this problem. Read on to learn how!
A reader recently asked what the fastest way to take an absolute value was. It occurred to me that there are a lot of ways to do this in Unity! So today we’ll try them all out and see which is best.
Calling into native code like C++ from C# is a powerful interoperability tool in Unity. As we move more and more code out of Mono and IL2CPP and into Burst, will we still have this tool available? Today we’ll find out!
Today we go back to basics and see how Burst compiles some fundamental language features:
switch statements and
ref parameters… with surprising results!