Hey there,
using Unity 2019.4.1f1
using URP 7.4.1
I created a shader using ShaderGraph where I can blend a texture onto the maintexture, in my case the Sprite used by the SpriteRenderer.
Now I also wrote a MonoBehaviour which is basically a conveniance script for my artist, who will attach this script to any sprite and will get a bunch of settings to adjust.
The texture to blend, tiling, offset, colors etc.
In this script I use OnValidate() to overwrite the MaterialPropertyBlock so only the material of the very selected GameObjects gets changed. And this works perfectly. In Edittime and in playmode, everythings looks as expected and gets changed the moment the settings are touched. Great.
Only problem: When I build the game and the scene loads I only see the basic sprites, without the “saved” changes. I found a workaround by using OnEnable() and calling the responsible logic for the adjustments, and that does indeed work.
It feels like the build process resets the material and when the game runs we have to manually “change” the materialpropertyblock with the serialized settings once again. Is this true?
The MaterialPropertyBlock doesn’t get serialized? Which at least feels weird, since the changes are still present when I switch scenes in the Editor or even restart the Editor.
Or is this a bug?