0

I'm trying to animate the property of a material so it changes on all objects its on, at once.

The property shows up in the Animation Timelines as (with spaces):

Sprite Renderer.Material._Distortion Blend

How do I access this keyword property in script and change it?

Confused
  • 6,048
  • 6
  • 34
  • 75

1 Answers1

2

Find out what type of property it is and then set it with one of the material Setter methods. Check this page out for a full list of the methods and read more about changing material\shader properties here. You can find the type of property in the shader you are using for the material.

You will be doing something similar to:

material.SetFloat("_DistortionBlend", 0.5f);
CaTs
  • 1,303
  • 10
  • 16
  • You more or less simply have to **know** how the properties of the target shader are called exactly. – derHugo Nov 30 '18 at 06:20
  • Does this recompile the shader each time its value is changed? Does it change the value for all use of this shader throughout the scene or just on this one object? It all seems very weird, to me. I don't get why it's so byzantine and bureaucratic to do something so useful. – Confused Nov 30 '18 at 06:23