The Core of C# Game Engines – and A bit about Unity

There is always 2 kinds of developers when it comes to gaming: There is the Developer Developing the Games, and the Developer developing the tools. In this particular article we talk about the Game Engine Core technology, but we cover in more detail C# technologies – among them the Unity Engine.

C# Game Engines

In a previous post, we covered a bit of how Lua Game Engines work at the core. But without a doubt the world today is dominated by the likes of technologies like Unity Game Engine – which has a portfolio of hits across multiple platforms (Established consoles, Mobile (Android / iOS), Web, Desktop, etc). Unity is behind Game Hits like the recent Fall Guys.

Disclaimer: Inspiration for this article comes from MonoGame – an Open Source C# Game Engine that is similar in some ways to Unity as a Core Engine.

What is the difference between how Lua works and how C# Works?

There are 2 I can say major preferences on Languages when it comes to Languages folks use to develop Games – these include – Lua and C#. Personally I believe C# has gotten prominence mostly due to the fact that Unity is quite a popular IDE / Tool, Lua is a veteran in this space. So what is the difference between these 2 languages when it comes to Architecture at the core?

In principle how C# is not so different from Lua in terms of how it technically works. The only difference is that the rift or divide between what is on C++ on the core and what is the high level C++ is huge – very huge when dealing with C#. Lua is designed to be like a more high level sibling of C++.

With C#, the C++ core is very much very well architectured and compiled to libraries even before C# touches any functionality coded on it.

Visual Architecture of C# Engines

C# Game Engines – How they are Architectured

As we can see, the C++ code is fully compiled into objects. That however does not mean these libraries solely originate from C++, other languages capable of compiling libraries can also take part in forming these libraries that C# can consume.

Integration with Low Level C++ (and other..) Binaries

The libraries are of 2 kinds:

  1. Platform independent – in which for instance a .dll can work on any platform.
  2. Or, platform specific dynamic libraries are compiled. These are mostly:
    1. .so files for Linux.
    2. .dll files for Windows.
    3. .dylib files for Mac.

C# has very established methods to bind into these dynamic libraries, and what Game Engine Core Developers do is they create Class Abstractions for how these Libraries are accessed, and they expose these Abstractions to the Game Developer. In essence, they are mostly taking advantage of very established Low Level Libraries compiled from C++.

Unity – and how their Eco-System is structured

In relation to the Core Engine that is C# – Unity went a step further and provided “add on tools” on top of the Engine Core, which comprises of the IDE / Unity Development Environment we all see, and the Products they offer as value add products / services. The Development Environment and these extra products allows you to use a number of tools and products they offer as part of the development experience you get, and they place it on top of the Game Engine Core. But they all blend so well to form one large Eco-System called Unity Game Engine – and provide powerful Game Development Experiences. Unity therefore goes a step further:

The Unity Eco-System of Products

So in essence, Game Code, together with Plugins and Extensions, and Developer Tools, all work together to produce Game Binaries. These Game Binaries then have functionality embedded to access addon Unity Functionalities through its Product Offering to provide a single breathtaking experience that is not just provided with the binary – but with the eco-system. These include: Multiplayer support, CDN support, Advertising and Monetization, etc etc.

In conclusion

The choice to use C# to abstract a lot of the core functionality for C++ and other very low level binary implementation of logic seems to be a very smart choice. C# as a language is very focused on providing the best interface for Object Oriented programmers, and since most entities are represented as Game Objects, it does a much better job compared to very many other programming language.

And it has an extra advantage – being built on top of the Mono Framework, C# is built to be cross platform. Its implementation is also as efficient as technologies like Java, C# and Mono tend to be very close to bare metal and native in implementation. I believe there is a lot of scope for C# and how it will scale. There is more to come.

Published by Ahmed Maawy

Ahmed Mohamed Maawy is a seasoned technologist with over a decade of experience growing and leading technology products across the African continent - Currently the VP for Engineering at Streamlytics. In his role as VP of Engineering at Streamlytics he leads engineering product development for both B2C and B2B products. Prior to Streamlytics his work spanned leading engineering at Griffin Kenya (an InsureTech Company) as the Chief Technology Officer to working for innovative and disruptive startups like EveryLayer Broadband, Ushahidi, and one of Time's Magazine 50 most genius companies BRCK; the only company in East Africa that designs its own complete hardware and software stack. Most recently he was at the Al Jazeera Media Network, working on both Digital & Broadcast technical integrations. He was part of the team that launched Al Jazeera’s streaming service AJ+ and was heavily involved in the organization's Media Archive Artificial Intelligence projects. Ahmed is a respected leader and pioneer in the Kenyan technology community, his work having been featured in Quartz Magazine, Fast Company & Huffington Post. He sits on the advisory board for CIO’s East African leading Internet of Things and Artificial Intelligence conference, the East Africa IoT and AI Summit.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: