- Home /
Moving from XNA
I've been looking up all the differences between XNA and Unity3d. I've figured out the easy ones like input, vector2, etc. My issue is I'm not finding something similar to Spritbatch. So like in xna you would call spritebatch.draw() to draw your 2d object. Could someone point me in the right direction?
I have a 2d framework in xna for a 2D game that I would like to bring over to Unity to continue my game. I'm not looking to spend money on frameworks already made for 2D games. I have my own and would to figure out the drawing part. As for most of it is just C# code except for the drawing and some other pieces of the code.
Answer by VesuvianPrime · Dec 12, 2014 at 06:41 PM
I first came to Unity from the Python PyGame module, OpenGL Glut, and C++ Allegro. These are all libraries in which you are responsible for drawing things directly to buffers as and when you need them.
Unity is completely opposite to this. In Unity you create your visual assets and instantiate them. You attach your behaviour functionalities as children (components) to these instances.
My first year or so with Unity was pretty tough as I was trying to force Unity to behave like these other engines, when Unity has it's very own paradigms.
I'd reccomend getting familiar with the relationship of GameObject and Component.
Thanks for the answer. I'll look into the GameObject and Component of the Unity Engine. Hopefully it won't take to long to figure it all out.
Answer by fafase · Dec 12, 2014 at 06:48 PM
From Xna lifecycle, Init/LoadContent could be assimilated to Awake/Start (Start is only call when the object is activated), Update is Update, UnloadContent is OnDestroy.
Draw would be LateUpdate as for when it happens but the purpose is not the same. Unity hides the rendering process while XNA still requires the call to send to the GPU. Forget about it here.
Note Unity has many more callbacks, I guess XNA had also but those are the main ones.
Also, XNA used virtual and override while Unity uses reflection to call a callback method from the lifecycle. Hence the absence of override on the front and no base.Method().
Yea all the Init/LoadContent, Update, and UnloadContent I've figured out. It is the spritebatch and how to draw things to the screen. Thanks for the answer This helped me a little.