I was having a chat with a number student early this morning at the Inter Uni Game Jam 2012 re Gameathons and Hacks they have attended. Ludum Dare seems to a great and popular online competition for rapid prototyped games. However it was clear from the discussions students building XNA were severely hindered due to the nature of Lumun Dare and its 1000s of competitors, the reason being, is that the majority of the competitors will only play games Online that don’t have to be complied so Flash and Unity web player games are really popular.
So we got onto discussing XNA to Unity or as its called UnityXNA which is simply a straightforward way of getting XNA games running in Unity3D. This was a rather interesting discussion with Ph.D student Luke Shares a member of the DevSoc team had actually already been experimenting with this and built a solution for the DevSoc 1st years for Lumun Dare entrys and we compared his work from Barnaby Smith, MVI Networks who has released a solution on GitHub at https://github.com/mvi/UnityXNA
What’s rather interesting is that MVI Networks solution, make Zero code changes to the original XNA game code. Barnaby has used a mixture of new code and some code from MonoXNA to implement XNA emulation by having a game object with a script attached run an XNA game performing updates and drawing.
A great walkthrough and analysis of UnityXNA can be found here http://darkgenesis.zenithmoon.com/xna-to-unityxna-and-beyond/
Implemented so far:
- Basic game loop and GameTime calculation.
- ContentManager loads Texture2Ds, SoundEffects and Songs, each wrapping the relevant Unity3D object.
- SpriteBatch Draw implemented using a draw queue, specifically created for the purpose. Currently supports colour tinting, source rectangles, and sprite effect flip modes.
- SpriteBatch DrawString has limited support, rendering the text in the correct position and with the correct colour.
- Support for playing Songs through MediaPlayer and playing SoundEffects
- KeyboardStates emulated for a limited set of keys which are mapped from their XNA values to Unity3D KeyCodes.
- Zero code changes to the game needed to run Platformer sample
Known issues, immediate areas for improvement:
- SpriteFont is not supported, all DrawStrings render with the default GUI Label font.
- Frame rate is currently vsync’d at 60 frames per second. When vsync is disabled GameTime is not calculated correctly.
- Windows Media Audio (.wma) is not supported by Unity3D, so I’ve converted the sample audio files to Ogg Vorbis (.ogg).
- Keyboard input is currently limited to a small set of keys, more mappings between XNA Keys and Unity3D KeyCodes need creating.
- Mouse, gamepad and touch input are not currently implemented.
So this is yet another way of getting your XNA Assets running as an Awesome Windows 8 or WindowsPhone 8 store application.