Now that I have some tutorials actually coming out, I thought I’d post them up here at the top in list-form so anyone clicking on this thread fresh will have easy access.
Tilengine + Unity: Basic Embedding
I ran across a new rendering engine a few months ago. Tilengine is a scan-line rendering engine written in C. It’s author made it open source a few months ago, the announcement of this was what drew my attention. (as well as a few youtube videos from Gamesfromscratch)
I had just learned how to program in Python, and I’ve been hungry for a performance-friendly solution for Raspberry Pi development for years. So I downloaded Tilengine, and started playing around with it. It took a little experimenting, but I got it running, and found it reasonably easy to work with. When I ran into a few limitations, I noticed that it’s documentation boasted of being able to embed the rendering engine as I pleased. I put this functionality to the test, and ran a trial to try and integrate Tilengine with Pygame. I would use Pygame for the window management, input, sound handling, etc… and just use Tilengine for the rendering. To my surprise, it worked like a charm. Rigging up Tilengine for this in Python turned out to be relatively easy and simple.
It was around this time that I started getting other ideas. Tilengine is written in C, which makes it extremely cross-platform porting friendly. It already has builds for several common platforms. It also comes with numerous bindings, allowing it to be used with a plethora of different languages. Python was just one option. And another option is C#. So, mad scientist that I am, I fired up Unity and began trying to integrate Tilengine into Unity, and possibly use it as an alternative 2D rendering solution.
Unity has capable tools for 2D rendering, tools that improve with every successive iteration. But one area that has always been difficult is retro pixel rendering. Unity is 3D at its core, and all of its 2D tools work on top of that 3D basis. This allows for some impressive visuals, depending on the style you are going for. But it also makes retro-pixel graphics a bit of a headache. Attempting to emulate that look in Unity is possible, but it takes some serious work-arounds and customization. So while I don’t think a Tilengine plug-in would ever be extensively used, I do think there would be some value to such a project. Pixel-pushers looking to work with more 90’s-style graphics could use it as an alternative to the look of typical Unity 2D rendering.
I’m still in-process with my experiment, but so far things have been progressing smoothly. I started off thinking I would use a RenderTexture, but that plan quickly redirected to using a Texture2D instance. Tilengine focuses on drawing pixel data to a byte array, and Texture2D just has way better tools for that. I can’t say for certain that I’ll be able to get this working, but I have been able to import the needed DLLs, reference the Tilengine Engine object, and even load up resources stored in my Assets folder. I’m feeling pretty good about this one.