This commit is contained in:
mob-sakai
2019-08-03 08:41:56 +09:00
parent 5b4ba5764e
commit 287c4b25bd
3 changed files with 48 additions and 27 deletions
@@ -0,0 +1,36 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// Changes in this scope cause the graphic's material to be dirty.
/// </summary>
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<UIEffectBase> ()
.Select (x => x.targetGraphic)
.Where (x => x);
foreach (var g in graphics)
{
g.SetMaterialDirty ();
}
}
base.CloseScope ();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16857cac7da564347876420ef55a734a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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<UIEffectBase> ()
.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);