Had a good look around these forums, and couldn't quite find the answer I was looking for, so here goes...
I'm working on a text effect for my title that uses a custom shader I've written that adds some noise and other effects to characters when they're rendered. The text is contained in a UILabel.
I created a Unity Material using my custom shader, and I'm feeding it some dynamic parameters at runtime (oscillating noise, etc.). The material is also setup to point to the correct Font Texture. I've then assigned this material to a UILabel, and it renders just fine. So far so good.
However, I'm finding that if I poke new values into the material at runtime, the UILabel doesn't update. It's as if it's created a local copy of the material internally and ignoring my dynamic changes.
Here's my setup...
label=textObject.GetComponent<UILabel>();
label.material=textMaterial;
And at runtime...
textMaterial.SetFloat("_MyShaderParameters",dynamicShaderValue);
I've tried clearing and re-setting the material each frame, but it never updates after it has first been assigned. I've tried all kinds of things - MarkAsChanged, SetDirty, Update, UpdateNGUIText, you name it. Nothing seems to help.
But rather curiously, if I change any of the other UILabel parameters in the editor inspector at runtime (in play mode), my material parameters suddenly get pushed through at the same time. So the material is "assigned" correctly.
Is there some kind of cache I need to invalidate, or other way I can get the UILabel to recognize the variables for assigned material has actually changed? I don't want to actually change which material I'm using after I assign it, I just want the UILabel to respect the material variables I'm changing dynamically.
Would appreciate any tips anybody has on this? Otherwise I fear I may have to revert back to using good ol' Text Mesh. :-(