2025-10-16 10:24:29 +09:00
|
|
|
using UnityEngine;
|
2025-12-11 18:26:09 +09:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2025-10-16 10:24:29 +09:00
|
|
|
|
|
|
|
|
public class Entity : MonoBehaviour
|
|
|
|
|
{
|
2025-11-04 11:02:02 +09:00
|
|
|
public string name;
|
2025-12-11 18:26:09 +09:00
|
|
|
public MaterialPropertyBlock mpb;
|
|
|
|
|
public List<MeshRenderer> renderers;
|
|
|
|
|
|
2025-10-16 10:24:29 +09:00
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
2025-12-11 18:26:09 +09:00
|
|
|
void Awake()
|
2025-10-16 10:24:29 +09:00
|
|
|
{
|
2025-12-11 18:26:09 +09:00
|
|
|
renderers = GetComponentsInChildren<MeshRenderer>().ToList();
|
|
|
|
|
mpb = new MaterialPropertyBlock();
|
2025-10-16 10:24:29 +09:00
|
|
|
}
|
|
|
|
|
|
2025-12-11 18:26:09 +09:00
|
|
|
public void SetColor(Color color)
|
2025-10-16 10:24:29 +09:00
|
|
|
{
|
2025-12-11 18:26:09 +09:00
|
|
|
foreach (var renderer in renderers)
|
|
|
|
|
{
|
|
|
|
|
mpb.SetColor("_BaseColor", color);
|
|
|
|
|
renderer.SetPropertyBlock(mpb);
|
|
|
|
|
}
|
2025-10-16 10:24:29 +09:00
|
|
|
}
|
|
|
|
|
}
|