diff options
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs')
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs new file mode 100644 index 0000000..aac679d --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using UnityEngine.EventSystems; + +namespace UnityEngine.UI +{ + [Obsolete("Use BaseMeshEffect instead", true)] + public abstract class BaseVertexEffect + { + [Obsolete("Use BaseMeshEffect.ModifyMeshes instead", true)] //We can't upgrade automatically since the signature changed. + public abstract void ModifyVertices(List<UIVertex> vertices); + }
+
+ // 关键在于实现IMeshModifier接口,自己写效果,不一定要继承这个类
+ [ExecuteInEditMode] + public abstract class BaseMeshEffect : UIBehaviour, IMeshModifier + { + [NonSerialized] + private Graphic m_Graphic; + + protected Graphic graphic + { + get + { + if (m_Graphic == null) + m_Graphic = GetComponent<Graphic>(); + + return m_Graphic; + } + } + + protected override void OnEnable() + { + base.OnEnable(); + if (graphic != null) + graphic.SetVerticesDirty(); + } + + protected override void OnDisable() + { + if (graphic != null) + graphic.SetVerticesDirty(); + base.OnDisable(); + } + + protected override void OnDidApplyAnimationProperties() + { + if (graphic != null) + graphic.SetVerticesDirty(); + base.OnDidApplyAnimationProperties(); + } + +#if UNITY_EDITOR + protected override void OnValidate() + { + base.OnValidate(); + if (graphic != null) + graphic.SetVerticesDirty(); + } + +#endif + + public virtual void ModifyMesh(Mesh mesh) + { + using (var vh = new VertexHelper(mesh)) + { + ModifyMesh(vh); + vh.FillMesh(mesh); + } + } + + public abstract void ModifyMesh(VertexHelper vh); + } +} |