From 287c4b25bd6462394c14c4a5ccf5d4ae112c541a Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sat, 3 Aug 2019 08:41:56 +0900 Subject: [PATCH] Refactor --- .../Scripts/Editor/MaterialDirtyScope.cs | 36 +++++++++++++++++++ .../Scripts/Editor/MaterialDirtyScope.cs.meta | 11 ++++++ .../Scripts/Editor/UIDissolveEditor.cs | 28 +-------------- 3 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs create mode 100644 Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs.meta diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs new file mode 100644 index 0000000..8e59a7f --- /dev/null +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs @@ -0,0 +1,36 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace Coffee.UIExtensions.Editors +{ + /// + /// Changes in this scope cause the graphic's material to be dirty. + /// + internal class MaterialDirtyScope : EditorGUI.ChangeCheckScope + { + readonly Object [] targets; + + public MaterialDirtyScope (Object [] targets) + { + this.targets = targets; + } + + protected override void CloseScope () + { + if (changed) + { + var graphics = targets.OfType () + .Select (x => x.targetGraphic) + .Where (x => x); + + foreach (var g in graphics) + { + g.SetMaterialDirty (); + } + } + + base.CloseScope (); + } + } +} \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs.meta b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs.meta new file mode 100644 index 0000000..c0c5053 --- /dev/null +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/MaterialDirtyScope.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 16857cac7da564347876420ef55a734a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs index 2450036..8d63aa1 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs @@ -14,32 +14,6 @@ namespace Coffee.UIExtensions.Editors [CanEditMultipleObjects] public class UIDissolveEditor : BaseMeshEffectEditor { - class ChangeMaterialScope : EditorGUI.ChangeCheckScope - { - Object [] targets; - public ChangeMaterialScope (Object [] targets) - { - this.targets = targets; - } - - protected override void CloseScope () - { - if (changed) - { - var graphics = targets.OfType () - .Select (x => x.targetGraphic) - .Where (x => x); - - foreach (var g in graphics) - { - g.SetMaterialDirty (); - } - } - - base.CloseScope (); - } - } - static int s_NoiseTexId; //################################ @@ -94,7 +68,7 @@ namespace Coffee.UIExtensions.Editors EditorGUILayout.PropertyField(_spSoftness); EditorGUILayout.PropertyField(_spColor); - using (new ChangeMaterialScope (targets)) + using (new MaterialDirtyScope (targets)) { EditorGUILayout.PropertyField (_spColorMode); EditorGUILayout.PropertyField (_spNoiseTexture);