From c47b92e92cf33ae8bf2f38929e137294397e4735 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 21:33:14 +0800 Subject: +init --- Assets/Scripts/Editor/MaterialDirtyScope.cs | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Assets/Scripts/Editor/MaterialDirtyScope.cs (limited to 'Assets/Scripts/Editor/MaterialDirtyScope.cs') 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 +{ + /// + /// Changes in this scope cause the graphic's material to be dirty. + /// When you change a property, it marks the material as dirty. + /// + 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()) + { + effect.SetMaterialDirty(); + } + } + + base.CloseScope(); + } + } +} -- cgit v1.1-26-g67d0