Files
XRLib/Assets/Scripts/Simulator/Model/Entity.cs
2025-12-11 18:26:09 +09:00

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);
}
}
}