diff options
Diffstat (limited to 'Assets/Scripts/Editor/MaterialDirtyScope.cs')
-rw-r--r-- | Assets/Scripts/Editor/MaterialDirtyScope.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Assets/Scripts/Editor/MaterialDirtyScope.cs b/Assets/Scripts/Editor/MaterialDirtyScope.cs new file mode 100644 index 0000000..435e66e --- /dev/null +++ b/Assets/Scripts/Editor/MaterialDirtyScope.cs @@ -0,0 +1,33 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace Coffee.UIEffects.Editors +{ + /// <summary> + /// Changes in this scope cause the graphic's material to be dirty. + /// When you change a property, it marks the material as dirty. + /// </summary> + internal class MaterialDirtyScope : EditorGUI.ChangeCheckScope + { + readonly Object[] targets; + + public MaterialDirtyScope(Object[] targets) + { + this.targets = targets; + } + + protected override void CloseScope() + { + if (changed) + { + foreach (var effect in targets.OfType<BaseMaterialEffect>()) + { + effect.SetMaterialDirty(); + } + } + + base.CloseScope(); + } + } +} |