static public ComponentDetail CreateDetail(Object obj, AssetFinderWindow assetFinder) { GameObject go = obj as GameObject; List <DetailButton> detailButtonList = new List <DetailButton>(); if (assetFinder.assetType == MATERIALS) { foreach (Renderer renderer in go.GetComponents <Renderer>()) { foreach (Material mat in renderer.sharedMaterials) { if (mat == assetFinder.filterMaterial) { GUIContent guiContent = EditorGUIUtility.ObjectContent(renderer, typeof(Renderer)); guiContent.tooltip = renderer.GetType().Name; detailButtonList.Add(new DetailButton(guiContent)); break; } } } } else if (assetFinder.assetType == TEXTURES) { foreach (Renderer renderer in go.GetComponents <Renderer>()) { foreach (Material mat in renderer.sharedMaterials) { if (mat != null) { Material material = mat; //Second reference to material that won't change and will be used by the delegate. Shader s = material.shader; if (!s.name.StartsWith(assetFinder.shaderName)) { continue; } int propCount = ShaderUtil.GetPropertyCount(s); for (int i = 0; i < propCount; i++) { if (ShaderUtil.GetPropertyType(s, i) == ShaderUtil.ShaderPropertyType.TexEnv) { string propName = ShaderUtil.GetPropertyName(s, i); if ((assetFinder.materialPropertyName.Equals("") || assetFinder.materialPropertyName.Equals(propName)) && material.HasProperty(propName)) { Texture texture = material.GetTexture(propName); if (texture == assetFinder.filterTexture) { GUIContent guiContent = EditorGUIUtility.ObjectContent(renderer, typeof(Renderer)); guiContent.tooltip = material.name + "(" + propName + ")"; detailButtonList.Add(new DetailButton(EditorGUIUtility.ObjectContent(renderer, typeof(Renderer)), delegate() { EditorGUIUtility.PingObject(material); } )); break; } } } } } } } } else if (assetFinder.assetType == MESHES) { MeshFilter mf = go.GetComponent <MeshFilter>(); if (mf != null && mf.sharedMesh == assetFinder.filterMesh) { GUIContent guiContent = EditorGUIUtility.ObjectContent(mf, typeof(MeshFilter)); guiContent.tooltip = mf.GetType().Name; detailButtonList.Add(new DetailButton(guiContent)); } SkinnedMeshRenderer smr = go.GetComponent <SkinnedMeshRenderer>(); if (smr != null && smr.sharedMesh == assetFinder.filterMesh) { GUIContent guiContent = EditorGUIUtility.ObjectContent(smr, typeof(SkinnedMeshRenderer)); guiContent.tooltip = smr.GetType().Name; detailButtonList.Add(new DetailButton(guiContent)); } foreach (MeshCollider mc in go.GetComponents <MeshCollider>()) { if (mc.sharedMesh == assetFinder.filterMesh) { GUIContent guiContent = EditorGUIUtility.ObjectContent(mc, typeof(MeshCollider)); guiContent.tooltip = mc.GetType().Name; detailButtonList.Add(new DetailButton(guiContent)); } } } return(new ComponentDetail(go, detailButtonList.ToArray())); }