Search Issue Tracker
By Design
Votes
0
Found in
4.3.0b3
Issue ID
565899
Regression
No
Reimporting a shader makes all materials in scene forget undeclared properties set from code
Reimporting a shader makes all materials in scene forget undeclared properties set from code.
This is kind-of-an-edge case. In the project, I have BuggyShader. It assigns the colour property to the emissive colour, but DOES NOT DECLARE IT in the properties block.
I have a script that assigns the colour on Start.
This works (which might be a bug since the colour is not exposed) - this is the same for any property, not just colour.
However, when I reimport ANY shader, the colour is forgotten (which kind of makes sense since it was never declared, and hence never saved). However, this is problematic, as it leads to very hard-to-find bugs in the shaders: If you forget to declare a material property, everything works as you expect. However, importing any shader suddenly introduces random breakage (I spent the entire day figuring out this was happening).
Ideally, I'd say that either
A) the property assignment should fail (as you haven't declared the property, effective making it one for Shader.SetGlobalXXX rather than Material.SetXXX)
B) If this is too evil for backwards compat, a warning in the editor on setting this property would be really helpful.
2) How can we reproduce it using the example you attached.
Open bugdemo.unity
Hit play
Notice the sphere turns red.
reimpoty "UnusedShader" in the project window.
Notice that the sphere loses it red
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [URP][OpenGL] "Trying to load color backbuffer into a complex RenderPass setup, results undefined" error is thrown when using Decal Projector
- Top and bottom color channels are swapped when lighting an object with Six Way Shader Graph in URP
- "Problem detected while importing the Prefab file" errors on Learning Templates import
- Crash on RaiseException during Socket.BeginConnect in Player when application connection is blocked through commercial firewall
- Decal Projector produces artifacts when the normal and decal are projected in negative z-direction and Normal Blend is set to 1
Add comment