Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
DepthEffect.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.UI;
4
5[AddComponentMenu("UI/ToJ Effects/Depth Effect", 2)]
6[RequireComponent(typeof(Text))]
7public class DepthEffect : BaseMeshEffect
8{
9 [SerializeField]
10 private Color m_EffectColor = new Color(0f, 0f, 0f, 1f);
11
12 [SerializeField]
13 private Vector2 m_EffectDirectionAndDepth = new Vector2(-1f, 1f);
14
15 [SerializeField]
16 private Vector2 m_DepthPerspectiveStrength = new Vector2(0f, 0f);
17
18 [SerializeField]
20
21 [SerializeField]
22 private bool m_UseGraphicAlpha = true;
23
24 private Vector2 m_OverallTextSize = Vector2.zero;
25
26 private Vector2 m_TopLeftPos = Vector2.zero;
27
28 private Vector2 m_BottomRightPos = Vector2.zero;
29
30 private List<UIVertex> m_Verts = new List<UIVertex>();
31
33 {
34 get
35 {
36 return m_EffectColor;
37 }
38 set
39 {
40 m_EffectColor = value;
41 if (base.graphic != null)
42 {
43 base.graphic.SetVerticesDirty();
44 }
45 }
46 }
47
49 {
50 get
51 {
53 }
54 set
55 {
56 if (!(m_EffectDirectionAndDepth == value))
57 {
59 if (base.graphic != null)
60 {
61 base.graphic.SetVerticesDirty();
62 }
63 }
64 }
65 }
66
68 {
69 get
70 {
72 }
73 set
74 {
75 if (!(m_DepthPerspectiveStrength == value))
76 {
78 if (base.graphic != null)
79 {
80 base.graphic.SetVerticesDirty();
81 }
82 }
83 }
84 }
85
87 {
88 get
89 {
91 }
92 set
93 {
95 if (base.graphic != null)
96 {
97 base.graphic.SetVerticesDirty();
98 }
99 }
100 }
101
102 public bool useGraphicAlpha
103 {
104 get
105 {
106 return m_UseGraphicAlpha;
107 }
108 set
109 {
110 m_UseGraphicAlpha = value;
111 if (base.graphic != null)
112 {
113 base.graphic.SetVerticesDirty();
114 }
115 }
116 }
117
118 protected DepthEffect()
119 {
120 }
121
122 protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color, int start, int end, float x, float y, float factor)
123 {
124 for (int i = start; i < end; i++)
125 {
126 UIVertex uIVertex = verts[i];
127 verts.Add(uIVertex);
128 Vector3 position = uIVertex.position;
129 position.x += x * factor;
130 if (depthPerspectiveStrength.x != 0f)
131 {
132 position.x -= depthPerspectiveStrength.x * ((position.x - m_TopLeftPos.x) / m_OverallTextSize.x - 0.5f) * factor;
133 }
134 position.y += y * factor;
135 if (depthPerspectiveStrength.y != 0f)
136 {
137 position.y += depthPerspectiveStrength.y * ((m_TopLeftPos.y - position.y) / m_OverallTextSize.y - 0.5f) * factor;
138 }
139 uIVertex.position = position;
140 Color32 color2 = color;
141 if (useGraphicAlpha)
142 {
143 color2.a = (byte)(color2.a * verts[i].color.a / 255);
144 }
145 uIVertex.color = color2;
146 verts[i] = uIVertex;
147 }
148 }
149
150 public override void ModifyMesh(VertexHelper vh)
151 {
152 if (!IsActive())
153 {
154 return;
155 }
156 vh.GetUIVertexStream(m_Verts);
157 int count = m_Verts.Count;
158 Text component = GetComponent<Text>();
159 int num = 0;
160 int num2 = m_Verts.Count;
162 {
163 num = m_Verts.Count - component.cachedTextGenerator.characterCountVisible * 6;
164 num2 = component.cachedTextGenerator.characterCountVisible * 6;
165 }
166 if (num2 == 0)
167 {
168 return;
169 }
171 {
172 m_TopLeftPos = m_Verts[num].position;
173 m_BottomRightPos = m_Verts[num + num2 - 1].position;
174 for (int i = num; i < num + num2; i++)
175 {
176 if (m_Verts[i].position.x < m_TopLeftPos.x)
177 {
178 m_TopLeftPos.x = m_Verts[i].position.x;
179 }
180 if (m_Verts[i].position.y > m_TopLeftPos.y)
181 {
182 m_TopLeftPos.y = m_Verts[i].position.y;
183 }
184 if (m_Verts[i].position.x > m_BottomRightPos.x)
185 {
186 m_BottomRightPos.x = m_Verts[i].position.x;
187 }
188 if (m_Verts[i].position.y < m_BottomRightPos.y)
189 {
190 m_BottomRightPos.y = m_Verts[i].position.y;
191 }
192 }
194 }
195 int num3 = num;
196 num3 = num;
197 int count2 = m_Verts.Count;
199 num3 = count2;
200 int count3 = m_Verts.Count;
202 num3 = count3;
203 int count4 = m_Verts.Count;
205 num3 = count4;
206 _ = m_Verts.Count;
209 {
210 List<UIVertex> range = m_Verts.GetRange(0, count - num2);
211 m_Verts.RemoveRange(0, count - num2);
212 m_Verts.InsertRange(m_Verts.Count - num2, range);
213 }
214 if (component.material.shader == Shader.Find("Text Effects/Fancy Text"))
215 {
216 for (int j = 0; j < m_Verts.Count - count; j++)
217 {
218 UIVertex value = m_Verts[j];
219 value.uv1 = new Vector2(0f, 0f);
220 m_Verts[j] = value;
221 }
222 }
223 vh.Clear();
224 vh.AddUIVertexTriangleStream(m_Verts);
225 }
226}
Vector2 m_DepthPerspectiveStrength
Definition: DepthEffect.cs:16
List< UIVertex > m_Verts
Definition: DepthEffect.cs:30
Vector2 m_TopLeftPos
Definition: DepthEffect.cs:26
Color m_EffectColor
Definition: DepthEffect.cs:10
Vector2 m_EffectDirectionAndDepth
Definition: DepthEffect.cs:13
bool onlyInitialCharactersGenerateDepth
Definition: DepthEffect.cs:87
void ApplyShadowZeroAlloc(List< UIVertex > verts, Color32 color, int start, int end, float x, float y, float factor)
Definition: DepthEffect.cs:122
Vector2 m_OverallTextSize
Definition: DepthEffect.cs:24
Color effectColor
Definition: DepthEffect.cs:33
override void ModifyMesh(VertexHelper vh)
Definition: DepthEffect.cs:150
Vector2 effectDirectionAndDepth
Definition: DepthEffect.cs:49
bool useGraphicAlpha
Definition: DepthEffect.cs:103
bool m_UseGraphicAlpha
Definition: DepthEffect.cs:22
Vector2 depthPerspectiveStrength
Definition: DepthEffect.cs:68
Vector2 m_BottomRightPos
Definition: DepthEffect.cs:28
bool m_OnlyInitialCharactersGenerateDepth
Definition: DepthEffect.cs:19