A strategy for puzzle games: Transform or RectTransform or both?
I'm making puzzle games - think 15 puzzle, Sudoku, 2048 and dozens of others. The common feature is that they tend to be grid or hex or tile-oriented, with each tile having reasonably complex behaviour. A tile might have a background, borders, arrows, paths, various symbols and also text. The attractiveness of the game comes from the design elements, the user interaction, especially animations, and of course the game play itself.
I've written one game using a mixture of UI(RectTransform) and sprite (Transform) elements. The camera is always orthographic, and using a Screen Space camera helped with the laying issues, but I'm finding it seriously difficult scaling between Transform (meter units) and RectTransform (pixel units) when they are displayed together.
So I'm looking for advice: should (a) I continue down this path and work on the scaling (b) switch everything to RectTransform (Canvas root) or (c) switch everything to Transform and work out how to draw text without the UI?
Even though this is a rather specific case, it goes without saying that knowing both approaches is a good thing. $$anonymous$$ost games use a mixture of UI elements, sprites, and meshes to build various features. $$anonymous$$nowing which is the strongest choice for a given element is often about experience, and what you want to do with the object in question.
You're going to be doing a lot of converting between coordinate systems, transformations, etc throughout your program$$anonymous$$g career. Look for opportunities to write methods which make it easier to share / convert data between these distinct systems, and avoid unnecessary complications by taking advantage of parenting, helper "dummy" objects, etc.
@alwayssunny: thanks for the comment. $$anonymous$$y question is really about the merits of working within a single paradigm as against intermixing them. I'm a bit past needing career advice and writing code is the easy bit. The main challenge is predicting what Unity will do in edge cases using mixtures of features that their developers didn't anticipate or plan for. It can take a lot of code to find out that some particular approach isn't going to work, or has unforeseen consequences.
As @michelle12188 elaborated, it's convenient to focus on a single pattern throughout a project, and where pixel perfection, literal scalability, and UX-centric features are concerned, the UI system's got you covered.
There will be the odd (in some projects, frequent) case where using UI elements to satisfy a requirement is a total nightmare, and it'd be wiser to depart. The point is that that's fine too. There are workarounds for any quirk that a mixed approach might introduce. I mix and match all the time; complex requirements demand it.
I personally prefer to use RectTransform and UI elements to do puzzle games like you are talking about. I find the system is much easier to layout/design and for 2D I find it tends to have less issues than working with Transform. I have done some mixing of RectTransform and Transform for games but mostly found it to be annoying to get just right as scaling is definitely a major issue.
Your answer
Follow this Question
Related Questions
UI GameObject (Button prefab) randomly changing Z axis RectTransform when instantiated 1 Answer
UI Canvas Anchor points are stuck in the bottom left corner and disabled when in overlay mode. 1 Answer
Transform.position not working- want to clamp object within confines of screen 0 Answers
UI Resets Position After Saving 0 Answers
Moving UI Image 0 Answers