how to change fog color with script ?
If you’re using the Editor you can hover over most attributes and it gives you a link straight to the API reference.
The API for fogColor
shows it’s part of pc.Scene
, which you can access through this.app.scene
.
So to change the color of the scene you can do:
this.app.scene.fogColor = new pc.Color(r, g, b, a);
this.app.scene.fogColor = new pc.Color(246, 227, 14, 1);
i tried with this code , play canvas editor shows perfect ,but while game running time shows full white color.
pc.Color
accepts float RGBA values ranging from 0…1 only. Bit confusing, I know. But you can simply divide your current values by 255 to get the float value. So you would do
this.app.scene.fogColor = new pc.Color(0.964, 0.89, 0.054, 1);
instead.
thank you , working fine…