Game Development Reference
In-Depth Information
Which to choose?
Each mode of the
Canvas Scaler
has its benefits and drawbacks, and you may
even end up using more than one type of
Ui Scale Mode
on separate Canvases
within a scene.
Planning a truly multiplatform UI is still hard, but at least Unity has now given you
much better tools and layouts than the old legacy GUI system, plus the full source
code should you wish to extend it in your own way.
Generally speaking, you will most likely use
Scale With Screen Size
mode
of the
Canvas Scaler
for your topmost
Canvas
as it offers the best resizing
options. However, the
Constant Physical Size
mode of
Canvas Scaler
is great for
those pixel-perfect UIs where you want everything just so, which you will most
likely use as a child Canvas of a top-level Canvas (remember, you can have any
kind of depth for the Canvas you wish).
Of course, you can forgo all of this and leave the
Canvas Scaler
alone and build
different UIs for each platform as before if you wish.
My best advice with all these options is to play with them and see
what works for you as each UI situation is different. Remember,
you are not limited in anyway, so if you want three parent
Canvases, all with different scaling options, then go wild or create
nested Canvases in your scene.
However, only use a new
Canvas
if you want to add the
Canvas
Scaler
to it or a different
Raycast
system, else just use an empty
GameObject and its
Rect Transform
to position, rotate, or scale
your UI panel/window.
Summary
Working on a UI in any format and making it work for multiple platforms is hard,
just ask any web developer who is building a responsive design for their website.
Coming up with a great UI design that works with your style of game is very
tricky; thankfully though, the new Anchor system provided by Unity goes a great
way to help you plan and layout your UI effectively. With the ever-increasing
fragmentation of screen real estate on mobile devices (even Apple is at it now with
multiple sizes of devices). It is more important than ever to get your UI working in
a true multi-platform fashion across all devices rather than making specific ones for
each resolution.