blob: ada9be88dd21118d7b5d87dce7cd69926e647a81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIEffects
{
/// <summary>
/// Dissolve effect for uGUI.
/// </summary>
[ExecuteInEditMode]
public class UISyncEffect : BaseMaterialEffect
{
[Tooltip("The target effect to synchronize.")] [SerializeField]
private BaseMeshEffect m_TargetEffect;
public BaseMeshEffect targetEffect
{
get { return m_TargetEffect != this ? m_TargetEffect : null; }
set
{
if (m_TargetEffect == value) return;
m_TargetEffect = value;
SetVerticesDirty();
SetMaterialDirty();
SetEffectParamsDirty();
}
}
protected override void OnEnable()
{
if (targetEffect)
targetEffect.syncEffects.Add(this);
base.OnEnable();
}
protected override void OnDisable()
{
if (targetEffect)
targetEffect.syncEffects.Remove(this);
base.OnDisable();
}
public override Hash128 GetMaterialHash(Material baseMaterial)
{
if (!isActiveAndEnabled) return k_InvalidHash;
var matEffect = targetEffect as BaseMaterialEffect;
if (!matEffect || !matEffect.isActiveAndEnabled) return k_InvalidHash;
return matEffect.GetMaterialHash(baseMaterial);
}
public override void ModifyMaterial(Material newMaterial, Graphic graphic)
{
if (!isActiveAndEnabled) return;
var matEffect = targetEffect as BaseMaterialEffect;
if (!matEffect || !matEffect.isActiveAndEnabled) return;
matEffect.ModifyMaterial(newMaterial, graphic);
}
public override void ModifyMesh(VertexHelper vh, Graphic graphic)
{
if (!isActiveAndEnabled) return;
if (!targetEffect || !targetEffect.isActiveAndEnabled) return;
targetEffect.ModifyMesh(vh, graphic);
}
#if UNITY_EDITOR
protected override void OnValidate()
{
SetVerticesDirty();
SetMaterialDirty();
SetEffectParamsDirty();
}
#endif
}
}
|