C# APIs are chock-full of generics. Generic types, generic method parameters, generic return types, generic fields, generic properties, deriving from generic types, and generic constructors. We can find all of these in the Unity and .NET APIs. Some are more frequent than others, but we’re going to need support for all of them to make C++ scripting a viable alternative to C#. Today’s article continues the series by adding just that: support for all of these kinds of generics. Let’s dive into how to use them as well as some bonus items added to the project this week.
Posts Tagged method
Callbacks are a mainstay of the real-time games and apps we build in Unity. We’re constantly writing asynchronous code for every operation from walking a character to a destination to making a web call. It’s really convenient for these functions to “call back” and report their status so we know how the operation is going. Unfortunately there are also a lot of dangers that come along with this. Today we’ll look into the surprisingly large number of ways you can “call back” in C# and some of the ways you can get burned doing so.
Reflection allows you to introspect your code at runtime. You can do very dynamic things like call functions by their name as a string. As such, it’s a really powerful tool when you code needs to be more flexible. Unfortunately, it’s slow. Really slow. Today’s article puts it up against regular, non-reflection code to show the difference in speed. It’ll also walk you through reflection in C# in case you’ve never used it before. Read on to learn more about reflection in Unity!
Continuing once again, today we cover an exciting new topic: generics! Have you ever wished your classes could be parameterized with a type like
Vector.<Type> is? With C# generics, you can! Even better, you can parameterize your interfaces, methods, and delegates too. Read on to learn how.
describeTypeJSON function is faster than the XML-based
describeType function by default, but we can make it even faster. Today’s article describe just how this is done and achieves a nearly 10x speedup!
You’ve probably seen built-in metadata tags like
[Embed], but have you ever wondered how you could add your very own, custom tags? Today’s article shows you how to add custom annotations to your AS3 classes and methods. Mark old methods of your library with
[Deprecated], file format classes with
[Version], or anything else you’d like. Today’s article shows you how.
Above all others, there is one article I refer back to most: 2009’s Function Performance. It was updated for Flash Player 10.1 and 10.2, but not 10.3, 11.0, 11.1, or 11.2. Today I’m updating this article for Flash Player 11.2, adding some missing function types, and including a set of graphs to make for the ultimate function performance reference.