- Home /
Should UI Canvas be used for games similar to 2048?
Hi guys. I'm trying to create a game that looks similar to 2048, however every tutorial I see about 2048, or even match 3/candy crash etc all seem to use UI canvas. I thought that would be wrong, I mean it doesn't seem natural for me. Besides I'm just learning unity and I'd like to avoid learning wrong way. Are there good reasons why everyone uses UI canvas? Should I just follow same instructions and use canvas since it's much harder to do other way? if not could you point me to any good tutorial/template that could be used in game like 2048.
If I had started this game by my current knowledge I would do it this way: draw how full grid should look like e.g in illustrator, than take parts from it: just background and tiles separately. Than I would place background as gameobject, and place tiles on it as separate gameobjects. Does this sound OK? Or am I swimming against the tide?
I can't think of any good reason not to make something like that using Unity's UI system. Why doesn't it seem natural to you?
Answer by UnityCoach · Nov 08, 2018 at 09:46 AM
You could use UI Canvases, as well as you can use Sprites.
The main difference will be in handling different aspect ratios and resolutions. With a Canvas, you can set it up to be "responsive", while with Sprites, you'll have to query the Screen width and height and adjust the Camera ortho size so that it properly frames your grid.
Performance wise, it's questionnable. The UI allows you to do very well optimised stuff, but the sorting lies with the parenting, which may make it harder to do.
If you decouple the mechanics from the display, you may start with Sprites and decide to switch to UI later.
Hope this helps.
Thanks for a clear response. So to make sure, this idea I have looks decent right?
If I had started this game by my current knowledge I would do it this way: draw how full grid should look like e.g in illustrator, than take parts from it: just background and tiles separately. Than I would place background as gameobject, and place tiles on it as separate gameobjects.
From here it seems like there's no advantage in using sprites solution generally, however for me it seems better solution since future projects wouldn't be possible to be created with canvas, so I'd better learn all aspects with sprites, and how to set up responsiveness with different aspect ratios/resolutions.
You can only learn by doing, and do by learning, right? So, you can only plan with what you already know. It's a bit empirical, and sure, if you knew everything you'll know by the end of the project, you would certainly do it differently, but you have to start with what you know. What you'll learn about Sprites will help you with UI later, as UI uses sprites anyway.
That said, the event catching system will be totally different if you do it with Sprites or UI. With UI everything is already there, but you'll have to learn about it all. With Sprites, there's almost nothing, you'll have to build it, but not so much to learn.
Unless you want to become a UI expert, I'd start with Sprites to learn, and eventually switch to UI for possible enhancements.
Your answer
Follow this Question
Related Questions
UI Elements Not Rendering Properly on Android 1 Answer
2D UI in 3D space 3 Answers
Maximum number of TextComponents/GameObjects 0 Answers
Choosing between canvas and normal 2D gameobjects 0 Answers
Use Unity canvas for a whole game? 1 Answer