3
\$\begingroup\$

When should I use one over the other? I'm pretty sure I understand the key differences, but I'm not sure which use cases would prefer one over the other. For example, let's say I have objects on the ground in my 3D game and they have UI Images above them with the objects' names. Which method is better? Should I stick to world space for objects which are located in the 3D world and screen space for overlay type stuff?

\$\endgroup\$
4
\$\begingroup\$

The Unity Canvas has three different modes, the two you're asking about are:

Screen Space-

This render mode places UI elements on the screen rendered on top of the scene.

This is the typical UI. It exists on top of everything else in the view. Useful for things like menus, heads up displays and overlays.

World Space-

In this render mode, the Canvas will behave as any other object in the scene.

This is for in-game UIs. Where you want the UI to appear to be like an object in game. Useful for nametags, in-game computer screens and diegetic interfaces.


Should I stick to world space for objects which are located in the 3D world and screen space for overlay type stuff?

Yes, that's exactly how you should use them. One is not better than the other, they are each better at different things.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Right on, thanks. When I asked which method was better, I meant specifically for the task of rendering UI labels above game objects in 3D space. In an isometric top-down-ish game where there are items on the ground, should I use world space or screen space? World space seems to make sense because the items that the labels are attached to exist in 3D space, but then the labels aren't rotated to face the camera. Is it worth sticking with world space and rotating them to correctly face the camera? \$\endgroup\$ – embracethefuture Jul 4 '17 at 9:06
  • \$\begingroup\$ World space, and add a script to make them face the camera. \$\endgroup\$ – MichaelHouse Jul 4 '17 at 14:36
  • \$\begingroup\$ The floating labels case has trade-offs. It's probably easiest to get up and running with the world-space canvas, but this has some side effects you might not want: 1) labels can be occluded by other objects in your scene. 2) by default, labels will shrink with distance in a perspective camera, which can make them harder to read, or huge & pixelated when close. 3) depending on your setup, they might get captured by shaders that mimic reflection & refraction of your scene, making them behave like in-world holograms rather than augmented reality overlays. \$\endgroup\$ – DMGregory Aug 12 '19 at 13:35
3
\$\begingroup\$

Unity Canvas are widely used and accordingly to Unity's documentation we have three types of it:

  1. Screen Space - Overlay

This render mode places UI elements on the screen rendered on top of the scene . If the screen is resized or changes resolution, the Canvas will automatically change size to match this.

GUI Canvas Screen Space - Overlay

  1. Screen Space - Camera

This is similar to Screen Space - Overlay, but in this render mode the Canvas is placed a given distance in front of a specified Camera . The UI elements are rendered by this camera, which means that the Camera settings affect the appearance of the UI. If the Camera is set to Perspective, the UI elements will be rendered with perspective, and the amount of perspective distortion can be controlled by the Camera Field of View. If the screen is resized, changes resolution, or the camera frustum changes, the Canvas will automatically change size to match as well.

GUI Canvas Screen Space - Camera

  1. World Space

In this render mode, the Canvas will behave as any other object in the scene. The size of the Canvas can be set manually using its Rect Transform, and UI elements will render in front of or behind other objects in the scene based on 3D placement. This is useful for UIs that are meant to be a part of the world. This is also known as a “diegetic interface”.

GUI Canvas World Space

The main difference is that in World Space the Canvas units are in metters whereas in Screen Space they are pixels relative to screen's resolution.

As rule of thumb, if we were to consider creating a VR environment we will probably use World Space Canvases instead of Screen Space Canvases (pretty much what you said).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.