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?
The Unity Canvas has three different modes, the two you're asking about are:
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.
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.
Unity Canvas are widely used and accordingly to Unity's documentation we have three types of it:
- 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.
- 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.
- 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”.
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).