using UnityEngine; using System.Collections.Generic; using System.Linq; public class Entity : MonoBehaviour { public string name; public MaterialPropertyBlock mpb; public List renderers; // Start is called once before the first execution of Update after the MonoBehaviour is created void Awake() { renderers = GetComponentsInChildren().ToList(); mpb = new MaterialPropertyBlock(); } public void SetColor(Color color) { foreach (var renderer in renderers) { mpb.SetColor("_BaseColor", color); renderer.SetPropertyBlock(mpb); } } }