- Home /
Question by
davidflynn2 · Sep 11, 2013 at 10:16 PM ·
c#textureanimatesubstance
Substance Texture Slider
I have been using the fallowing script to move the slider of my substance texture back and forth and cause it to animate but now I need to make it so when it reaches the max number instead of going backwards over time to the start, it jumps back to the start and starts again. So basically it goes thought he animation then instantly jumps back to the start and starts again.
Here is the code I have been using.
public string floatRangeProperty = "";//This allows you to type in the name of the property you want to animate in the inspector.
public float cycleTime = 0;//This allows you to set the speed at which it animates.
void Update()
{
ProceduralMaterial substance = renderer.sharedMaterial as ProceduralMaterial;//This finds the substance texture and allows you to use it.
if (substance)//Checks if this is a substance.
{
float lerp = Mathf.PingPong(Time.time * 2 / cycleTime, 100);//This PingPongs the values so it cannot get larger than the substance max and min and move it over time.
substance.SetProceduralFloat(floatRangeProperty, lerp);//This sets the part of the substance you are controlling.
substance.RebuildTextures();//This rebuilds the texture each update to make the changes.
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
how to make substance material (subtance designer) 1 Answer
Texture on plane not displaying properly 0 Answers