Tanoda
EditorSelectAllMissingMaterials.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4#if UNITY_EDITOR
5using UnityEditor;
6#endif
7using NaughtyAttributes;
8
9public class EditorSelectAllMissingMaterials : MonoBehaviour
10{
11#if UNITY_EDITOR
12 public Material findThis;
13 [Button]
14 void SelectAllMissingMaterial()
15 {
16 var allmr = GetComponentsInChildren<MeshRenderer>();
17 var mrList = new List<MeshRenderer>();
18 foreach (var meshRenderer in allmr)
19 {
20 if (meshRenderer.sharedMaterial == null || (findThis && meshRenderer.sharedMaterial == findThis))
21 {
22 mrList.Add(meshRenderer);
23 }
24 }
25
26 Selection.objects = mrList.ToArray();
27
28 }
29#endif
30}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7