Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3.  
  4. using System;
  5. using System.Linq;
  6. using System.IO;
  7. using System.Collections.Generic;
  8. using System.Reflection;
  9. using System.Text.RegularExpressions;
  10.  
  11. using UnityEngine.AssetBundles.GraphTool;
  12. using Model=UnityEngine.AssetBundles.GraphTool.DataModel.Version2;
  13.  
  14. [CustomFilter("Filter By Texture Alpha")]
  15. public class FilterByTextureAlpha : IFilter {
  16.  
  17. [SerializeField] private bool m_hasAlpha;
  18.  
  19. public string Label {
  20. get {
  21. return m_hasAlpha ? "With Alpha" : "No Alpha";
  22. }
  23. }
  24.  
  25. public FilterByTextureAlpha() {
  26. m_hasAlpha = false;
  27. }
  28.  
  29. public bool FilterAsset(AssetReference a) {
  30.  
  31. if(a.filterType != typeof(TextureImporter)) {
  32. return false;
  33. }
  34.  
  35. var textureImporter = AssetImporter.GetAtPath(a.importFrom) as TextureImporter;
  36.  
  37. return textureImporter.DoesSourceTextureHaveAlpha() == m_hasAlpha;
  38. }
  39.  
  40. public void OnInspectorGUI (Action onValueChanged) {
  41.  
  42. using (new EditorGUILayout.HorizontalScope()) {
  43. var newValue = EditorGUILayout.ToggleLeft("Texture has Alpha channel", m_hasAlpha);
  44.  
  45. if (newValue != m_hasAlpha) {
  46. m_hasAlpha = newValue;
  47. onValueChanged();
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement