mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 18:02:38 +08:00
Refactor
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user