Skip to content

Instantly share code, notes, and snippets.

@vml-rmott
Created September 3, 2018 21:49
Show Gist options
  • Save vml-rmott/6fe126299b4cb5a8c4306a92eb943100 to your computer and use it in GitHub Desktop.
Save vml-rmott/6fe126299b4cb5a8c4306a92eb943100 to your computer and use it in GitHub Desktop.
Proxy materialForRendering properties for Timeline animation
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
[ExecuteInEditMode]
public class AnimateMaskableGraphic : MonoBehaviour {
private Material m_Material;
[Range(0f, 1f)]
public float maskWipeControl;
void Awake()
{
// Cache a reference to object's material.
m_Material = GetComponent<MaskableGraphic>().materialForRendering;
}
IEnumerator AnimateProperties()
{
while (true)
{
// add other properties as needed
m_Material.SetFloat("_MaskWipeControl", maskWipeControl);
yield return new WaitForEndOfFrame();
}
}
void Start()
{
StartCoroutine(AnimateProperties());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment