Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
CurveEffect.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.UI;
4
5[AddComponentMenu("UI/ToJ Effects/Curve Effect", 6)]
6[RequireComponent(typeof(Text))]
7public class CurveEffect : BaseMeshEffect
8{
9 public enum CurveMode
10 {
13 }
14
15 [SerializeField]
17
18 [SerializeField]
19 private AnimationCurve m_Curve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 2f), new Keyframe(1f, 0f, -2f, 0f));
20
21 [SerializeField]
22 private float m_Strength = 1f;
23
24 private List<UIVertex> m_Verts = new List<UIVertex>();
25
26 public AnimationCurve curve
27 {
28 get
29 {
30 return m_Curve;
31 }
32 set
33 {
34 if (m_Curve != value)
35 {
36 m_Curve = value;
37 if (base.graphic != null)
38 {
39 base.graphic.SetVerticesDirty();
40 }
41 }
42 }
43 }
44
45 public float strength
46 {
47 get
48 {
49 return m_Strength;
50 }
51 set
52 {
53 if (m_Strength != value)
54 {
55 m_Strength = value;
56 if (base.graphic != null)
57 {
58 base.graphic.SetVerticesDirty();
59 }
60 }
61 }
62 }
63
64 protected CurveEffect()
65 {
66 }
67
68 public override void ModifyMesh(VertexHelper vh)
69 {
70 if (!IsActive())
71 {
72 return;
73 }
74 vh.GetUIVertexStream(m_Verts);
75 if (m_Verts.Count == 0)
76 {
77 return;
78 }
79 Vector2 zero = Vector2.zero;
80 Vector2 zero2 = Vector2.zero;
81 if (m_CurveMode == CurveMode.FullRect)
82 {
83 Rect rect = GetComponent<RectTransform>().rect;
84 zero = new Vector2(rect.xMin, rect.yMax);
85 zero2 = new Vector2(rect.xMax, rect.yMin);
86 }
87 else
88 {
89 zero = m_Verts[0].position;
90 zero2 = m_Verts[m_Verts.Count - 1].position;
91 for (int i = 0; i < m_Verts.Count; i++)
92 {
93 if (m_Verts[i].position.x < zero.x)
94 {
95 zero.x = m_Verts[i].position.x;
96 }
97 if (m_Verts[i].position.y > zero.y)
98 {
99 zero.y = m_Verts[i].position.y;
100 }
101 if (m_Verts[i].position.x > zero2.x)
102 {
103 zero2.x = m_Verts[i].position.x;
104 }
105 if (m_Verts[i].position.y < zero2.y)
106 {
107 zero2.y = m_Verts[i].position.y;
108 }
109 }
110 }
111 float num = zero2.x - zero.x;
112 for (int j = 0; j < m_Verts.Count; j++)
113 {
114 UIVertex value = m_Verts[j];
115 value.position.y += curve.Evaluate((value.position.x - zero.x) / num) * strength;
116 m_Verts[j] = value;
117 }
118 vh.Clear();
119 vh.AddUIVertexTriangleStream(m_Verts);
120 }
121}
override void ModifyMesh(VertexHelper vh)
Definition: CurveEffect.cs:68
float strength
Definition: CurveEffect.cs:46
List< UIVertex > m_Verts
Definition: CurveEffect.cs:24
AnimationCurve m_Curve
Definition: CurveEffect.cs:19
AnimationCurve curve
Definition: CurveEffect.cs:27
float m_Strength
Definition: CurveEffect.cs:22
CurveMode m_CurveMode
Definition: CurveEffect.cs:16