Hello All. There is a problem setting the skybox material at run time. I use this code to change it:
RenderSettings.skybox = _skybox; //Material
then as manual says I call
DynamicGI.UpdateEnvironment ();```
But it does not update ambient light source and reflections. :-/
It only resets reflection and ambient light, when I pass **null** as the new skybox material, And when later I set existing material back nothing happens (the skybox image changes, but neither the ambient source nor reflections do).
I noticed that if I do it in editor, and then touch defaultReflectionMode (switch it to Custom, then back to Skybox), everything updates according to the new skybox. And in the status bar I see the message "*1/3 Reflection probes | 1 jobs*". But I do not use any reflection probes!
I tried this in the script, but with no luck:
```csharp
//touch the reflection type to accept the new skybox
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Skybox;
So I’m totally lost. Is there a correct way to change the skybox material at runtime with correct reflections and ambient color?
I’m curious if your problem might be the older version of Unity. Can you upgrade or are you tied to it?
If you can’t upgrade, then is your entire project source-controlled properly? If it is fully backed-up or otherwise source-controlled, clone it and then open it with a newer version of Unity.
If 2018/2019 proves too problematic, open it with Unity 5.6.7, as that is fairly smooth-running these days (I still support it a bit despite using modern Unity), and hasn’t drifted too far from 5.2.
Also, are you at least on 5.2.2 because 5.2.0 had a lot of problems, IIRC.
I’m on 5.2.4 just because of its DX9 support. I have also 2019.1.2f1 installed. And I plan to use it to build the project for WebGL. Yes, I have full control on the source and I can clone it as I wish. It’s a good idea to try it in the newer version, But I try to keep things as simple as I can.I think it’s much easier to upgrade the project forward from an older version than to downgrade it later from a newer one, So I want to have a solid working project in 5.x, and a possibility to upgrade it to newer ones on demand.
And the problem described above doesn’t look like a bug, but I just do something wrong, so I ask All to share his experience. There must be someone who fought such a problem before.
And thank you for the 5.6.7 idea. I’ll give it a try, if it can run the build on older hardware.
update. Unity 5.6.7 does all the same. It updates reflections in the editor, but not in play mode. It looks like it has some hidden reflection probe somewhere, and inits it when I set defaultReflectionMode = Skybox (manually). So, the question is - what the function does it call to create this hidden probe, and is it accessible in the play mode?