0x03 Canvas的Render Mode
Render Mode主要用于定义UI如何渲染于屏幕之上。通常一个Scene只需一个Canvas即可,不过Canvas自身也是支持嵌套的,默认情况下,子Canvas与父Canvas的Render Mode保持一致。
Screen Space-Overlay
此模式下,Canvas会被缩放以适应屏幕,然后直接渲染到屏幕上,无需任何摄像机。屏幕尺寸或者分辨率改变了,UI会自动进行缩放,UI会覆盖所有其他摄像机的画面。
该模式下需要特别注意:Canvas需要放在Hierarchy所有元素的顶层,否则UI可能会从视图中消失。这是Unity内置的限制。
原文:Note: The Screen Space - Overlay canvas needs to be stored at the top level of the hierarchy. If this is not used then the UI may disappear from the view. This is a built-in limitation. Keep the Screen Space - Overlay canvas at the top level of the hierarchy to get expected results.