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