Posts Tagged method

C++ For C# Developers: Part 11 – Struct Functions

Tags: , , ,

Now that we’ve covered the basics of structs, let’s add functions to them! Today we’ll explore member functions and overloaded operators.

Read the rest of this article »

3 Comments

C++ Scripting: Part 10 – Full Generics Support

Tags: , , , , , , ,

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.

Read the rest of this article »

No Comments

The Many Types and Dangers of Callbacks

Tags: , , , , ,

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.

Read the rest of this article »

2 Comments

Unity Reflection is Really Slow

Tags: , , , ,

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!

Read the rest of this article »

13 Comments

From AS3 to C#, Part 11: Generic Classes, Interfaces, Methods, and Delegates

Tags: , , , ,

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.

Read the rest of this article »

12 Comments

Making describeTypeJSON 50x Faster than describeType

Tags: , , , , , , , , , , ,

The hidden 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!

Read the rest of this article »

1 Comment

Custom AS3 Annotations

Tags: , , ,

You’ve probably seen built-in metadata tags like [SWF] and [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.

Read the rest of this article »

2 Comments

Function Performance Update

Tags: , , , , , , , ,

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.

Read the rest of this article »

4 Comments