Search Issue Tracker
Won't Fix
Votes
0
Found in
2019.4
2019.4.0f1
2020.2
Issue ID
1260403
Regression
No
Different phenomenon when SetPropertyBlock is called with and without a materialIndex parameter
How to reproduce:
1. Open the attached "MaterialPropertyBlockAnimation" project
2. Open the Sample Scene and Enter the Play mode
3. Inspect the Game view
Actual: Animation cannot change the property of material when SetPropertyBlock with index parameter is called
Reproducible with: 2019.4.4f1, 2020.2.0a18
Note:
Could not test 2018.4 because the project breaks when downgraded
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Mobile] Developer Console does not appear when an error is thrown
- [HDRP] Game view renders artifacts when Camera's Component "Post Anti-aliasing" is set to "TAA" and Dynamic Resolution's "Forced Screen Percentage" is changed
- A deactivated Prefab's name color becomes white when a GameObject in the scene is deactivated
- The Game view becomes blank when using Frame Debugger with MSAA and Texture binding enabled in Play Mode
- NullReferenceException is thrown when changing the Inspector preview selection
Resolution Note:
After looking into this and getting confirmation from the graphics team, this is actually expected behaviour.
The documentation ( https://docs.unity3d.com/ScriptReference/Renderer.SetPropertyBlock.html ) does mention that in the case of per-renderer and per-material overrides being used, per-material will be used over per-renderer, which is triggered by using SetPropertyBlock with the materialIndex, suggesting that different behaviours should be expected. Looking further into the animation side of things, when it sets the float of the material property being animated, it'll set it to the per-renderer ShaderPropertySheet, however in the renderer, the per-renderer property sheet is then overridden by the per-material property sheet if it's being used - which in the case of using SetPropertyBlock with materialIndex, they are, and which is why it would appear that animation does not work.