52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class Example : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private bool GenerateInstances = true;
|
|
|
|
private void Awake()
|
|
{
|
|
if (!GenerateInstances)
|
|
{
|
|
return;
|
|
}
|
|
int num = 0;
|
|
string text = string.Empty;
|
|
MeshFilter[] array = Object.FindObjectsOfType<MeshFilter>();
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
if (i % 2 == 0)
|
|
{
|
|
Mesh mesh = array[i].mesh;
|
|
text = text + mesh.ToString() + " ";
|
|
num++;
|
|
}
|
|
}
|
|
Debug.Log("Instantiated " + num + " meshes. " + text);
|
|
num = 0;
|
|
text = string.Empty;
|
|
MeshRenderer[] array2 = Object.FindObjectsOfType<MeshRenderer>();
|
|
for (int j = 0; j < array2.Length; j++)
|
|
{
|
|
if (j % 2 == 0)
|
|
{
|
|
Material material = array2[j].material;
|
|
text = text + material.ToString() + " ";
|
|
num++;
|
|
}
|
|
}
|
|
SkinnedMeshRenderer[] array3 = Object.FindObjectsOfType<SkinnedMeshRenderer>();
|
|
for (int k = 0; k < array3.Length; k++)
|
|
{
|
|
if (k % 2 == 0)
|
|
{
|
|
Material material2 = array3[k].material;
|
|
text = text + material2.ToString() + " ";
|
|
num++;
|
|
}
|
|
}
|
|
Debug.Log("Instantiated " + num + " materials. " + text);
|
|
}
|
|
}
|