When the background type of the scene is set to solid color, the rendering area of the canvas will be filled with the corresponding solid color background before the camera renders.
Navigate to Hierarchy Panel -> Select Scene -> Inspector Panel -> Background Section and set Mode to Solid Color, then choose the desired background color. You will see the background of the scene change in real-time.
Similarly, you can also set it in the script with the following code:
// 获取当前场景的背景实例
const background = scene.background;
// 设置背景类型为纯色
background.mode = BackgroundMode.SolidColor;
// 设置特定的背景色
background.solidColor.set(0.25, 0.25, 0.25, 1.0);
// 设置为(0,0,0,0) 可以透出网页背景
background.solidColor.set(0, 0, 0, 0);
It is important to note that the relevant properties of the background are all in the background
property of the scene. After obtaining this property instance, you need to modify the relevant properties for them to take effect.
Property | Function |
---|---|
solidColor | Sets the background color |