Today we’ll add two new types to the Native Collections suite: NativeIntPtr
and NativeLongPtr
. We’ll make them usable with both IJob
and IJobParallelFor
and explore some new features Unity’s native container system along the way.
Archive for category Unity
There are a lot of ways to write C# code that has no effect. One common way is to initialize class fields to their default values: public int Value = 0;
. Today we’ll go over five types of useless code and see what effect it has on the actual machine code that the CPU executes. Do IL2CPP and the C++ compiler always do the right thing? Let’s find out!
Monads sound fancy, but sometimes they’re actually really simple and useful. Today we’ll look at the Maybe
monad, which is a low-overhead tool that’s extremely useful to prevent bugs.
Two weeks ago we tested the performance of the async
and await
keywords plus the C# Task
system against Unity’s new C# jobs system. This tested the usual combination of async
and await
with the Task
system, but didn’t test the Task
system directly against Unity’s C# jobs system. Today we’ll test that and, in so doing, see how to use the Task
system without the async
and await
keywords.
Last week’s article tested the performance of the async
and await
keywords plus the C# Task
system against Unity’s new C# jobs system. This week we’ll go in depth with async
and await
to learn how they work, how they relate to the Task
system, and how we can customize them for our own uses.
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!
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>
.
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).
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.
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!