- Home /
 
 
               Question by 
               Sondre-S · Aug 17, 2016 at 09:05 AM · 
                shadersfindtransparent  
              
 
              Find all transparent shaders
I've written this script to easily find all transparent objects and set them to occludee and remove the occluder flag before baking occlusion. Is there a way to find all shaders with the transparent property so I don't have to reference each one by their full name?
  using UnityEditor;
  using UnityEngine;
  
 public class SetTransparentObjectsToOcludee
 {
     [MenuItem("Edit/SetTransparentObjectsToOcludee")]
     public static void DoCheck()
     {
         var newFlags = StaticEditorFlags.BatchingStatic | StaticEditorFlags.LightmapStatic | StaticEditorFlags.OccludeeStatic;
         foreach(MeshRenderer mr in Object.FindSceneObjectsOfType(typeof(MeshRenderer)))
         {
             foreach(Material matt in mr.sharedMaterials)
             {
                 if(matt.shader== Shader.Find("Transparent/Glow2"))
                 {
                     GameObjectUtility.SetStaticEditorFlags(mr.transform.gameObject, newFlags);
                 }
             }
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer