XNA and Unity3D developers unite! UnityXNA
- Posted: Aug 15, 2012 at 6:00 AM
- 8,092 Views
- 5 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
You all know I have a soft spot in my heart for XNA. Since it first came out and let me create games for my XBox 360, I've been a fanboy of it. You also know that I'm a fanboy of gaming engines, like Unity3D.
So when I saw the two mixed in this proof of concept, a example of running XNA inside of Unity3D (let alone that the Platformer Sample was used), well...
I had a theory that it would be straightforward to get XNA games running in Unity3D so I decided to give it a go.
This is a proof of concept showing the Platformer XNA sample running inside Unity3D. Zero code changes have been made to the original game code. Using a mixture of new code and some code from MonoXNA I’ve implemented XNA emulation by having a game object with a script attached run an XNA game performing updates and drawing.
You can see the game in your browser here and download the source here.
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.
If you're interested in seeing how it's done, check out the source on Github here.
If you just want to see it work, via the Unity3D Web Player, check it out here.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Wow, please continue with this. This would make it much easier to port XNA games.
This looks good ! Can you convert a Unity3d game into XNA as well with this ?
@Mark: No, I don't believe so
Checkout https://github.com/fehaar/FFWD for that.
Hi, this is what I was looking for :)
I have a finished project in XNA but I want to run it in Unity3D.
Can you explain a little more how I import my project to Unity and how to structure the files?
thanks so much
Remove this comment
Remove this thread
close