cwisbg

ChangeColor

Jan 9th, 2019
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [ExecuteInEditMode]
  6. public class ChangeColor : MonoBehaviour {
  7. public Color NewColor = new Color(0, 0, 0);
  8. public bool DoUpdate = true;
  9. void DoColorUpdate()
  10. {
  11. MeshRenderer rend = GetComponent<MeshRenderer>();
  12. rend.material.SetColor("_Color", NewColor);
  13. }
  14. void Update () {
  15. if (DoUpdate)
  16. {
  17. DoColorUpdate();
  18. DoUpdate = false;
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment