XNA inside UNITY3D for Ludum Dare Student/Institutional Entries

 

Unity_logi XNA

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.

As I discussed in a previous blog  Flash .SWF games can be ported to Unity using UniSwf see https://www.uniswf.com

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 https://darkgenesis.zenithmoon.com/xna-to-unityxna-and-beyond/

Also if your interested in seeing the XNA Platform sample running in Unity you can see the game in your web browser here and download the source here.

Implemented so far:

  1. Basic game loop and GameTime calculation.
  2. ContentManager loads Texture2Ds, SoundEffects and Songs, each wrapping the relevant Unity3D object.
  3. SpriteBatch Draw implemented using a draw queue, specifically created for the purpose. Currently supports colour tinting, source rectangles, and sprite effect flip modes.
  4. SpriteBatch DrawString has limited support, rendering the text in the correct position and with the correct colour.
  5. Support for playing Songs through MediaPlayer and playing SoundEffects
  6. KeyboardStates emulated for a limited set of keys which are mapped from their XNA values to Unity3D KeyCodes.
  7. Zero code changes to the game needed to run Platformer sample

Known issues, immediate areas for improvement:

  1. SpriteFont is not supported, all DrawStrings render with the default GUI Label font.
  2. Frame rate is currently vsync’d at 60 frames per second. When vsync is disabled GameTime is not calculated correctly.
  3. Windows Media Audio (.wma) is not supported by Unity3D, so I’ve converted the sample audio files to Ogg Vorbis (.ogg).
  4. Keyboard input is currently limited to a small set of keys, more mappings between XNA Keys and Unity3D KeyCodes need creating.
  5. 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.