Unity 2018.1 brought us two asynchronous code systems. First, there’s C# 5’s async
and await
keywords in conjunction with the Task
and Task<T>
types. Second, there’s Unity’s own C# jobs system. There are many differences, but which is faster? Today’s article puts them to the test to find out!
Async & Await vs. Unity Jobs
Enumerables Without the Garbage: Part 8
NativeArray<T>
is great, but very limited in functionality. We can fix this surprisingly easily! Today we revive a two year old series that created the iterator project. Iterators are like a no-GC version of IEnumerable<T>
and LINQ which have a lot of power but only support managed arrays (T[]
) and List<T>
. Today we’ll add support for NativeArray<T>
and inherit support for the same functionality. We’ll also spruce up the project with proper unit tests, assembly definitions, and runtime tests to confirm that zero garbage is created. Read on to see how this was done and how to use iterators with NativeArray<T>
.
NativeLinkedList<T>: Part 4
Today we wrap up the series by completing the NativeLinkedList<T>
type. We’ll only add a few new functions this time and focus on improving the correctness of the existing code with respect to Unity’s native collections system. We’ll also add performance tests to validate whether all of this work has any practical usefulness (hint: it does).
NativeLinkedList<T>: Part 3
Last time in the series we encountered and overcame a host of esoteric issues on our path to a better understanding of Unity’s native collection system. This week we’ll continue on that journey and grapple with even more challenges in this new, unexplored area of Unity.
NativeLinkedList<T>: Part 2
Continuing from last time, today we’ll greatly expand on the fledgling NativeLinkedList<T>
that we started last time. By the end of the article, we’ll have a useful native collection available to us!
NativeLinkedList<T>: Part 1
Unity 2018.1 shipped with just one true native container: NativeArray<T>
. Now Unity 2018.2 has been released and there is still just the one native container. We’ve seen how to implement more, but never wrote much more than a proof of concept. Today we’ll begin implementing NativeLinkedList<T>
as an example of a native container for a very well known, simple data type. The result is available on GitHub for any project to use.
How Unity’s C# Job Types Are Implemented
Unity provides IJob
, IJobParallelFor
, and IJobParallelForTransform
and it turns out these are written in C# so we can learn how they’re implemented. Today’s article goes through each of them so we can learn more about how they work and even see how we can write our own custom job types.
Do More With C# Jobs
My Job System Tutorial listed many Unity APIs accessible from C# jobs, but the list was incomplete. Today I’ll add on to the list with some newly-released 2018.2 features as well as some powerful 2018.1 features that were left off of the last article. Many of these aren’t documented in Unity’s release notes. Read on to learn more about what you can do with C# jobs!
Just How Much Garbage Does LINQ Create?
LINQ’s CPU performance is quite poor, but how is it with memory? Does every LINQ function always create tons of garbage for the GC to collect, or are there exceptions that aren’t so bad? Today’s article tests out lots of LINQ functions to find out!
How FixedUpdate Works
Many Unity programmers misunderstand FixedUpdate
because it seems so basic. Usually it behaves in the simplistic way it’s thought to work, but there are important exceptions that are often forgotten. Today we’ll take a closer look at FixedUpdate
to get a better handle on how it works and learn to use it correctly.