Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- using System;
- using System.Linq;
- using System.IO;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Text.RegularExpressions;
- using UnityEngine.AssetBundles.GraphTool;
- using Model=UnityEngine.AssetBundles.GraphTool.DataModel.Version2;
- [CustomFilter("Filter By Texture Alpha")]
- public class FilterByTextureAlpha : IFilter {
- [SerializeField] private bool m_hasAlpha;
- public string Label {
- get {
- return m_hasAlpha ? "With Alpha" : "No Alpha";
- }
- }
- public FilterByTextureAlpha() {
- m_hasAlpha = false;
- }
- public bool FilterAsset(AssetReference a) {
- if(a.filterType != typeof(TextureImporter)) {
- return false;
- }
- var textureImporter = AssetImporter.GetAtPath(a.importFrom) as TextureImporter;
- return textureImporter.DoesSourceTextureHaveAlpha() == m_hasAlpha;
- }
- public void OnInspectorGUI (Action onValueChanged) {
- using (new EditorGUILayout.HorizontalScope()) {
- var newValue = EditorGUILayout.ToggleLeft("Texture has Alpha channel", m_hasAlpha);
- if (newValue != m_hasAlpha) {
- m_hasAlpha = newValue;
- onValueChanged();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement