Created
September 3, 2018 21:49
-
-
Save vml-rmott/6fe126299b4cb5a8c4306a92eb943100 to your computer and use it in GitHub Desktop.
Proxy materialForRendering properties for Timeline animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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