space-shmup/Assets/__Scripts/Utils.cs
2024-03-14 18:40:19 -05:00

20 lines
505 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Utils : MonoBehaviour
{
// Returns a list of all Materials on this GameObject and its children
static public Material[] GetAllMaterials(GameObject go) {
Renderer[] rends = go.GetComponentsInChildren<Renderer>();
List<Material> mats = new List<Material>();
foreach(Renderer rend in rends) {
mats.Add(rend.material);
}
return(mats.ToArray());
}
}