summaryrefslogtreecommitdiff
path: root/Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs')
-rw-r--r--Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs79
1 files changed, 79 insertions, 0 deletions
diff --git a/Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs b/Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs
new file mode 100644
index 0000000..3fefbd3
--- /dev/null
+++ b/Assets/UI_Extension/Scripts/Effects/BaseUIEffect.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.EventSystems;
+using UnityEditor;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Graphic))]
+public abstract class BaseUIEffect
+ : UIBehaviour
+ , IMeshModifier
+ , IMaterialModifier
+{
+ [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 void ModifyMesh(Mesh mesh)
+ {
+ using (var vh = new VertexHelper(mesh))
+ {
+ ModifyMesh(vh);
+ vh.FillMesh(mesh);
+ }
+ }
+
+ public virtual void ModifyMesh(VertexHelper vh)
+ {
+ }
+
+ public virtual Material GetModifiedMaterial(Material baseMaterial)
+ {
+ return baseMaterial;
+ }
+
+}