Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Announcing UnityXNA – XNA Inside Unity3D

Discussion in 'General Discussion' started by I am da bawss, Jul 8, 2012.

  1. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    I didn't do this. This is NOT mine. I just saw this from some blog....

    Announcing UnityXNA – XNA Inside Unity3D



    http://mvinetwork.co.uk/2012/07/07/announcing-unityxna-xna-inside-unity3d/

    "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.


    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."



    Proof of Concept Live in Browser
    Download source code at GitHub
     
    Last edited: Jul 8, 2012
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
  3. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Ops, thought I did. Fixed.
     
  4. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Interesting idea. Would this allow users to put their XNA games on the Mac (and soon to be Linux) platforms?
     
  5. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    This is very interesting :)

    I know XNA a bit so might as well use it with unity3D :)
     
  6. ZeroByteDNA

    ZeroByteDNA

    Joined:
    Jun 18, 2012
    Posts:
    1,042
    Interesting concept...I miss XNA at times, it seems so long ago (because I didn't use XNA for WP/XB).
     
  7. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,797
    No idea why anybody would want to use XNA over or in Unity (aside from being able to release games for XBox Live.)
     
  8. echtolion

    echtolion

    Joined:
    Jun 16, 2011
    Posts:
    140
    You can already do this with monogame.
     
  9. Heinz2001

    Heinz2001

    Joined:
    Jul 8, 2012
    Posts:
    5
    I like this project. Very clever idea.

    I thought of using monogame for other platforms, but for Android and iOS i need Monotouch/Monodroid and the licenses are too expensive. So this solution is easy and the number of target platforms are increased.

    I exported your sample to Android and it runs great on my mobile. I hope you push this forward and you include gamepad and touch handling. Maybe i can help.

    Kepp up good work!

    cheers
     
  10. ZeroByteDNA

    ZeroByteDNA

    Joined:
    Jun 18, 2012
    Posts:
    1,042
    There are Windows games that have come out in the past year using XNA that have done well on Steam.

    It could come down to a user's experience with XNA - certain beliefs they may have, etc. Personally, when I think about actual 2D or 2.5D - I do not think about Unity - I think XNA or some other product. There's a difference between TD/SV pseudo 2D in a 3D engine and dealing with depth layers in a 2D framework. It's always been one of the things that's caused me problems with Unity - 3D art vs. 2D art. I'm not an artist/animator, nor do I have the funds to toss around to buy the assets for it.

    Still, MS ticked me off with the major push of XNA in a certain direction a couple years back... so I've been trying to port my XNA stuff over to Unity here and there while working on other things.
     
  11. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    This shouldn't turn into an advocacy war, and I'm not here to slag off Unity, but I think relegating XNA to 2D and 2.5D is doing it a disservice. Surely XNA is a better (and cheaper) choice if you need more direct control over the render pipeline? I haven't pushed Unity hard in this direction, but that's largely because I don't see any evidence that it's practical. Even if it's possible, as far as I'm aware it's not at all comfortable.

    XNA has a really well designed network layer, and great support for customized asset conversion. And it's actually possible to write a pause feature in XNA, which seems totally impossible in Unity. There are plenty of reasons why you might want to work at a lower level, and while Unity's engine is great for what it does, it is frustrating when it doesn't allow you to dig into something that really should be possible.

    Those benefits obviously don't apply when you're just programming to XNA's API within Unity, but there are certainly reasons (minus networking) why you might prefer pure XNA over Unity for PC game development. You will need to implement more things yourself (or find middleware), but there is a real benefit to the extra control you get.
     
  12. ZeroByteDNA

    ZeroByteDNA

    Joined:
    Jun 18, 2012
    Posts:
    1,042
    Not a case of relegating XNA to that in the least, simply a case that when thinking about 2D/2.5D...I do not think of Unity. That's not the same as saying when I think of 3D, I do not think of XNA...because I would include XNA while thinking about 3D.

    Of course, part of that comes down to XNA being a framework and Unity being an engine. It's not really fair, so to speak, to compare them in that sense.
     
  13. Heinz2001

    Heinz2001

    Joined:
    Jul 8, 2012
    Posts:
    5
    XNA is a great choice if you currently don't know what is your target platform.

    * Monogame (Mono implementation of XNA) targets: Windows/MacOSX/Linux/Android (MonoDroid)/IOS (MonoTouch) PSSuite
    * UnityXNA targets: Win/MacOSX/Flash/Android/IOS/Wii/PS3/XBOX
    * XNA targets: Win7/Win8/WP7/XBOX

    I think this are good reasons to choose XNA (or a limits set of XNA features).
     
  14. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    What problems are you having with a pause feature in Unity?
     
  15. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    The only way I'm aware of is to set the time scale to zero, but this affects everything, making things like UI transitions harder to handle. You can do them based on realtimeSinceStartup, but that's kind of nasty. Maybe there's a better way, though.
     
  16. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    Eh, I'm doing that and it's really not difficult to use realtimeSinceStartup. It might be nice if they offered a realDeltaTime and if stuff like animation could be flagged to use it instead of regular deltaTime, but it's easy to do it yourself. Certainly not "totally impossible" in Unity, cos I've done it :)
     
  17. maetheec

    maetheec

    Joined:
    Jun 26, 2012
    Posts:
    31
    To me XNA is really just a wrapper over DirectX, it's barely more than just a graphic library with some basic math and shader stuff on top (not including the XBLA specific stuff). While Unity is a full blown engine... so using XNA in unity doesn't sound "logical" to me unless you have some code for an XNA game that you want to port into iOS/Android or something along that line.
     
  18. LucasDaltro

    LucasDaltro

    Joined:
    Oct 31, 2010
    Posts:
    236
    That's exactly the objective of that tool.And besides that I'm thinking about port my game to xna manually and use it on xbox360.
     
  19. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    Anyone seen Mono Engine http://monogame.codeplex.com/ runs xna 4 framework with openGL which can publish to windows phones in addition to the rest?
     
  20. Heinz2001

    Heinz2001

    Joined:
    Jul 8, 2012
    Posts:
    5
    Monogame cannot target WP7. Only XNA as i said, couple of posts above.
     
  21. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,614
    Still unsure as to why this would happen, but I guess it's useful in some sense. When I read it I was expecting a bit more, but still very surprised!
     
  22. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    i think this is very interesting.. immma look into this more because i have a xbox creators account....
     
  23. Khyrid

    Khyrid

    Joined:
    Oct 8, 2010
    Posts:
    1,790
    I wonder what the licencing restrictions would be? I guess you have to own everything. Does XNA take royalties, if you publish a XNA game inside Unity Pro, you have to own pro and pay Microsoft?
     
  24. Heinz2001

    Heinz2001

    Joined:
    Jul 8, 2012
    Posts:
    5
    XNA is only an API and Monogame is a free implementation for it. UnityXNA is nearly the same. You have to respect UnityXNA license and if UnityXNA includes Monogame code you have to respect this license as well.
     
  25. MarkcusD

    MarkcusD

    Joined:
    Jul 12, 2011
    Posts:
    40
    What I want is an easy way to port my unity game to xna so I can put it on live indie.
     
  26. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
  27. MarkcusD

    MarkcusD

    Joined:
    Jul 12, 2011
    Posts:
    40
    Exactly what I wanted. I'll give it a try.
     
  28. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    Interesting.. I'd like to see that developed more for a 360 release..