using System; using System.Collections.Generic; using UnityEngine.EventSystems; namespace UnityEngine.UI { [Obsolete("Use BaseMeshEffect instead", true)] /// /// Obsolete class use BaseMeshEffect instead. /// public abstract class BaseVertexEffect { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] [Obsolete("Use BaseMeshEffect.ModifyMeshes instead", true)] //We can't upgrade automatically since the signature changed. public abstract void ModifyVertices(List vertices); } /// /// Base class for effects that modify the generated Mesh. /// /// /// /// .Get(); /// /// for (int i = 0; i < verts.Count; i++) /// { /// var vert = verts[i]; /// uvs.Add(new Vector2(verts[i].x, verts[i].y)); /// verts[i] = vert; /// } /// mesh.SetUVs(1, uvs); /// ListPool.Release(uvs); /// } ///} /// ]]> /// /// [ExecuteAlways] public abstract class BaseMeshEffect : UIBehaviour, IMeshModifier { [NonSerialized] private Graphic m_Graphic; /// /// The graphic component that the Mesh Effect will aplly to. /// protected Graphic graphic { get { if (m_Graphic == null) m_Graphic = GetComponent(); 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(); } /// /// Called from the native side any time a animation property is changed. /// 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 /// /// Function that is called when the Graphic is populating the mesh. /// /// The generated mesh of the Graphic element that needs modification. public virtual void ModifyMesh(Mesh mesh) { using (var vh = new VertexHelper(mesh)) { ModifyMesh(vh); vh.FillMesh(mesh); } } public abstract void ModifyMesh(VertexHelper vh); } }