+7 (495) 987 43 74 ext. 3304
Join us -              
Рус   |   Eng

Authors

Frolov S.

Degree
Engineer, SYSTEMNAYA DINAMIKA
E-mail
sergey_a_frolov@mail.ru
Location
Moscow
Articles

C# event manager design in Unity3D. Usability and productivity evaluation

During a Unity3D-based application development arose a problem of the best approach to a modular architecture. Main requirements were extensibility of a system via plugin mechanism, good performance within single main loop, aggressive garbage collection tolerance, low memory footprint and minimal amount of allocations. Event-driven architecture has been chosen as the one fitting the bill. This paper describes three different approaches to a message exchange within such an architecture, their relative ease of use, ease of maintenance and performance. Message exchange mechanisms being reviewed are: C# native events, event manager with event and publisher types tracking, static events lists with responsibility demarcation and tight IDE integration. All three methods are supposed to be used inside Unity3D version 4 hence being single-threaded and .NET 3.5 compatible. In the end static events lists approach has proven itself although a little bit more verbose than the two other methods, however the best one in terms of performance and IDE integration. The best thing about the selected approach is the fact that it shifts considerable part of an abstraction overhead into an application compile phase rather than runtime. Considering all being said static events lists approach is the best one to use within Unity3D applications.
Read more...