Posts Tagged events

Replacing Events in MV-C

Tags: , , , ,

This article shows you how to remove events from the MV-C design pattern to make it simpler to understand, safer to use, and faster to execute. It’s a step-by-step lesson in refactoring. Start by reading the MV-C article, then read on!

Read the rest of this article »

22 Comments

Fastest Callbacks: Delegate, Event, or Interface?

Tags: , ,

How fast are C# delegates and events? The best answer is “compared to what?”. You probably use callbacks all the time, but what’s the fastest kind of callback? C# delegates and events are nice, built-in features of C#, but you could also implement your own callback interface. Would that gain you any speed? Read on for the performance test and results!

Read the rest of this article »

8 Comments

WebCall: A Class to Make Web Calls Cleaner and Easier

Tags: ,

Today’s article is about WebCall, a class to make Unity’s WWW cleaner and easier to use. How could it be cleaner or easier than it already is? By adding C# events! Normally your web calls have lots of clutter around them, your logic gets split across functions, and handling the call is hard when the GameObject or MonoBehaviour get destroyed. WebCall solves all these problems so your web calls are clean, easy, and robust. Read on for the source code and examples!

Read the rest of this article »

5 Comments

How To Use C# Events In Unity DLLs

Tags: ,

DLLs—like SWCs in Flash—are an extremely handy way to build your code into reusable modules. Unfortunately, Unity has some quirks that can lead to crashes on iOS and other environments that don’t support JIT compilation. The biggest problem that crops up is when you try to use C# events in a DLL. Today’s article investigates why and where the problem occurs and presents a simple solution to work around the problem. Read on to learn how to safely use C# events in Unity DLLs!

Read the rest of this article »

6 Comments

Unity Editor Integration with Pure Code

Tags: ,

One apparent downside to the “pure code” approach to Unity app code design is that it makes less use of the Unity Editor. Because it only uses one main MonoBehaviour, there aren’t a lot of MonoBehaviour classes that can be modified by the Inspector panel- a mainstay in Unity design and debugging. Today’s article introduces another kind of auxiliary MonoBehaviour to work around this issue enabling you to use the “pure code” approach without sacrificing the Inspector panel.

Read the rest of this article »

2 Comments

From AS3 to C#, Part 9: Even More Special Functions

Tags: ,

Last week’s article continued the discussion of special types of functions in C#’s class system, including variable numbers of arguments (“var args”), indexers, and conversion operators. Today’s article should finish up the topic of special functions. Read on to learn about the built-in support for delegates, events, and object initializers!

Read the rest of this article »

3 Comments

Errors During Dispatch

Tags: , , ,

In my recent work related to events and signals, I had a little discussion about errors that are thrown during the dispatch of an event or signal. I did some investigating to see how EventDispatcher handles this and found something rather surprising.

Read the rest of this article »

2 Comments

Introducing TurboSignals

Tags: , ,

My last article on Callback Strategies highlighted some pretty severe performance differences between my Runnable strategy, as3signals by Robert Penner, and Flash’s native Event system. My simple Runnable technique had an artificial advantage though: it was not a proper library but instead a little bit of code built right into the test app. Today I’m introducing TurboSignals as an AS3 library making use of the Runnable technique.

Read the rest of this article »

45 Comments

Callback Strategies

Tags: , , , , ,

I’ve previously covered ways of implementing in my article on Runnables (aka observers) which showed how to call back about 15 times faster than just using a Function object. There are still more ways to call back though and I didn’t cover them at the time. Today I’ll be adding to Function and Runnables by testing Event and the as3signals library by Robert Penner.

Read the rest of this article »

19 Comments

Removing Event Listeners

Tags:

Making sure you remove event listeners is good for both correctness and garbage collection. Sometimes you don’t want (or need) to hear events any more and some times you just need to release references to aid the garbage collector in memory cleanup. Whatever your reason, there are a few ways to do it.

Read the rest of this article »

2 Comments