Control unity shader graph using script.
public float Duration = 1;
public Material mat;
private float solve = 0 ;
private bool press = true;
void Update()
{
StartCoroutine(wait());
}
IEnumerator wait()
{
yield return new WaitForSeconds(2f);
if (press)
{
solve += Time.deltaTime / Duration;
mat.SetFloat("Dissolve", solve);
}
if (solve > 1)
{
press = false;
}
}
hello i am controlling shader graph value using script . What i want is to make it snap back to 0 after it reach 1 or if i exit the playmode mid way i tried many ways but not working. If anyone can help that will be really helpful to me. thanks
Comment