- Home /
Why does Accessing an instance of ProceduralAnimation stop the animation?
Ok, so I have a ProceduralMaterial that's animated, and I use it as the material for my Shields. Now each shield can be a different color, so I've written a script that allows you to change parameters of the ProceduralMaterial. My code changes it in the inspector, but the material still draws in it's original color, unless I click the Randomize button in the PM's inspector (or change any of it's variables), at which point it paints correctly. If I add .RebuildTexturesImmediately(); or .RebuildTextures(); it does create the correctly colored material, but it stops the animation. In the inspector the Animation box is checked, and the Speed is set correctly, but it doesn't generate any new textures.
Here's my code:
void Start () {
theShield = transform.GetComponent<MeshRenderer>();
// get this instance of the material
substance = (ProceduralMaterial)theShield.material;
}
void Update () {
// Set the Shield's properties
substance.SetProceduralColor("Liquid_Color", MainColor);
substance.SetProceduralFloat("Speed", Frequency);
//substance.RebuildTexturesImmediately();
}
Again, as it is, it's animated with the wrong color (original). If I uncomment that last line, then it's the correct color, but it's no longer animated.
I've also tried putting all the commands in the Start, and then the shield starts the correct color, but again, the PM doesn't generate any new textures. Am I not setting a parameter correctly?
Nothing? No one knows about working with Substances? I suppose I could write a script that would also generate the textures, but that seems like it would have more overhead than this.
Your answer
![](https://koobas.hobune.stream/wayback/20220612065644im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I use Substance materials in Unity? 2 Answers
Material(string) is obsolete. How else can a shader be loaded at runtime? 2 Answers
Substance question 2 Answers
How to properly modify a multi-material object shader? 0 Answers
is there a way to make a gradient material, white to black, in Unity3D? 2 Answers