Hey, I was wondering if anyone could help me out?
I’m not a programmer but was wondering if anyone knew of a command or script that could show me what materials if any are using a texture with RGBA in my scene?
Thanks,
K
Hey, I was wondering if anyone could help me out?
I’m not a programmer but was wondering if anyone knew of a command or script that could show me what materials if any are using a texture with RGBA in my scene?
Thanks,
K
many image formats have alpha channel
using UnityEngine;
using UnityEditor;
using System.Collections;
public class FindRGBA : MonoBehaviour {
[MenuItem ("Custom/Find All With Alpha")]
public static void FindAll () {
TextureFormat[] formats = new TextureFormat[] {
TextureFormat.RGBA32,
TextureFormat.ARGB32,
TextureFormat.ARGB4444,
TextureFormat.DXT5,
TextureFormat.PVRTC_RGBA2,
TextureFormat.PVRTC_RGBA4,
TextureFormat.ATC_RGBA8,
TextureFormat.BGRA32
};
Object[] renderes = GameObject.FindObjectsOfType(typeof(MeshRenderer));
foreach (Object render in renderes) {
MeshRenderer meshRenderer = render as MeshRenderer;
foreach (Material material in meshRenderer.sharedMaterials) {
Texture2D texture2D = material.mainTexture as Texture2D;
foreach (TextureFormat format in formats) {
if (texture2D.format == format) {
Debug.Log("material=" + material.name + "&texture=" + texture2D.name + "&format=" + format.ToString());
break;
}
}
}
}
Debug.Log("Done.");
}
}