Updating Property of Custom UI Image Material at Runtime
I have a material assigned to a UI Image component that uses a custom shader that is a modified version of the UI Default shader. The sprite that is assigned to the Image has a gradient ramp in the alpha channel. I have added a property called "Cutoff" to the custom shader which works in conjunction with the alpha values to clip the sprite pixels as the value moves from 0 to 1, creating a "fill" effect. The material is functioning properly in the editor, but I am having trouble updating the "Cutoff" value of the material used by the Image at runtime. I can see that the "Cutoff" value is changing if I retrieve the value from the material, but the Image is not reflecting the changes. I believe that the Image is creating a copy of the material that I can not access. I've tried setting the float property "Cutoff" of both image.material and image.canvasRenderer.GetMaterial(), but neither have given me results. Is there a way to access the actual material instance being used to render the Image during runtime, or force it to update?
Your answer
Follow this Question
Related Questions
How can I set an Image (PNG) from a URL to be the material of a sphere ?? 0 Answers
How to change the render mode of a material in runtime? 0 Answers
Creating a Score/Highscore image at runtime 0 Answers
Textures are pure white in project window 1 Answer
Change texture from file on runtime (Windows / macOS) 0 Answers