Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
OverlayTexture Class Reference
Inheritance diagram for OverlayTexture:

Public Types

enum  TextureMode { Local , GlobalTextArea , GlobalFullRect }
 
enum  ColorMode { Override , Additive , Multiply }
 

Public Member Functions

override void ModifyMesh (VertexHelper vh)
 
virtual Material GetModifiedMaterial (Material baseMaterial)
 

Public Attributes

Texture2D m_OverlayTexture
 

Protected Member Functions

 OverlayTexture ()
 
override void Start ()
 

Properties

TextureMode textureMode [get, set]
 
ColorMode colorMode [get, set]
 
Texture2D overlayTexture [get, set]
 

Private Member Functions

void Update ()
 

Private Attributes

TextureMode m_TextureMode
 
ColorMode m_ColorMode
 
bool m_NeedsToSetMaterialDirty
 
Material m_ModifiedMaterial
 
List< UIVertex > m_Verts = new List<UIVertex>()
 

Detailed Description

Definition at line 8 of file OverlayTexture.cs.

Member Enumeration Documentation

◆ ColorMode

Enumerator
Override 
Additive 
Multiply 

Definition at line 17 of file OverlayTexture.cs.

◆ TextureMode

Enumerator
Local 
GlobalTextArea 
GlobalFullRect 

Definition at line 10 of file OverlayTexture.cs.

Constructor & Destructor Documentation

◆ OverlayTexture()

OverlayTexture.OverlayTexture ( )
inlineprotected

Definition at line 87 of file OverlayTexture.cs.

88 {
89 }

Member Function Documentation

◆ GetModifiedMaterial()

virtual Material OverlayTexture.GetModifiedMaterial ( Material  baseMaterial)
inlinevirtual

Definition at line 175 of file OverlayTexture.cs.

176 {
177 if (!IsActive())
178 {
179 return baseMaterial;
180 }
181 if (baseMaterial.shader != Shader.Find("Text Effects/Fancy Text"))
182 {
183 Debug.Log("\"" + base.gameObject.name + "\" doesn't have the \"Fancy Text\" shader applied. Please use it if you are using the \"Overlay Texture\" effect.");
184 return baseMaterial;
185 }
186 if (m_ModifiedMaterial == null)
187 {
188 m_ModifiedMaterial = new Material(baseMaterial);
189 }
190 m_ModifiedMaterial.CopyPropertiesFromMaterial(baseMaterial);
191 m_ModifiedMaterial.name = baseMaterial.name + " with OT";
192 m_ModifiedMaterial.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
193 m_ModifiedMaterial.shaderKeywords = baseMaterial.shaderKeywords;
194 m_ModifiedMaterial.CopyPropertiesFromMaterial(baseMaterial);
195 m_ModifiedMaterial.EnableKeyword("_USEOVERLAYTEXTURE_ON");
196 m_ModifiedMaterial.SetTexture("_OverlayTex", overlayTexture);
197 m_ModifiedMaterial.SetInt("_OverlayTextureColorMode", (int)colorMode);
199 return m_ModifiedMaterial;
200 }
Texture2D overlayTexture
ColorMode colorMode
bool m_NeedsToSetMaterialDirty
Material m_ModifiedMaterial

References colorMode, Debug, m_ModifiedMaterial, m_NeedsToSetMaterialDirty, Material, and overlayTexture.

◆ ModifyMesh()

override void OverlayTexture.ModifyMesh ( VertexHelper  vh)
inline

Definition at line 99 of file OverlayTexture.cs.

100 {
101 if (!IsActive())
102 {
103 return;
104 }
105 vh.GetUIVertexStream(m_Verts);
106 int count = m_Verts.Count;
107 if (m_Verts.Count == 0)
108 {
109 return;
110 }
111 if (textureMode == TextureMode.GlobalTextArea || textureMode == TextureMode.GlobalFullRect)
112 {
113 Vector2 zero = Vector2.zero;
114 Vector2 zero2 = Vector2.zero;
115 if (textureMode == TextureMode.GlobalFullRect)
116 {
117 Rect rect = GetComponent<RectTransform>().rect;
118 zero = new Vector2(rect.xMin, rect.yMax);
119 zero2 = new Vector2(rect.xMax, rect.yMin);
120 }
121 else
122 {
123 zero = m_Verts[0].position;
124 zero2 = m_Verts[m_Verts.Count - 1].position;
125 for (int i = 0; i < m_Verts.Count; i++)
126 {
127 if (m_Verts[i].position.x < zero.x)
128 {
129 zero.x = m_Verts[i].position.x;
130 }
131 if (m_Verts[i].position.y > zero.y)
132 {
133 zero.y = m_Verts[i].position.y;
134 }
135 if (m_Verts[i].position.x > zero2.x)
136 {
137 zero2.x = m_Verts[i].position.x;
138 }
139 if (m_Verts[i].position.y < zero2.y)
140 {
141 zero2.y = m_Verts[i].position.y;
142 }
143 }
144 }
145 float num = zero.y - zero2.y;
146 float num2 = zero2.x - zero.x;
147 for (int j = 0; j < count; j++)
148 {
149 UIVertex value = m_Verts[j];
150 value.uv1 = new Vector2(1f + (value.position.x - zero.x) / num2, 2f - (zero.y - value.position.y) / num);
151 m_Verts[j] = value;
152 }
153 }
154 else
155 {
156 for (int k = 0; k < count; k++)
157 {
158 UIVertex value = m_Verts[k];
159 value.uv1 = new Vector2(1 + ((k % 6 != 0 && k % 6 != 5 && k % 6 != 4) ? 1 : 0), 1 + ((k % 6 != 2 && k % 6 != 3 && k % 6 != 4) ? 1 : 0));
160 m_Verts[k] = value;
161 }
162 }
163 vh.Clear();
164 vh.AddUIVertexTriangleStream(m_Verts);
165 }
List< UIVertex > m_Verts
TextureMode textureMode

References m_Verts, and textureMode.

◆ Start()

override void OverlayTexture.Start ( )
inlineprotected

Definition at line 91 of file OverlayTexture.cs.

92 {
93 if (base.graphic != null)
94 {
95 base.graphic.SetMaterialDirty();
96 }
97 }

◆ Update()

void OverlayTexture.Update ( )
inlineprivate

Definition at line 167 of file OverlayTexture.cs.

168 {
169 if (m_NeedsToSetMaterialDirty && base.graphic != null)
170 {
171 base.graphic.SetMaterialDirty();
172 }
173 }

References m_NeedsToSetMaterialDirty.

Member Data Documentation

◆ m_ColorMode

ColorMode OverlayTexture.m_ColorMode
private

Definition at line 28 of file OverlayTexture.cs.

◆ m_ModifiedMaterial

Material OverlayTexture.m_ModifiedMaterial
private

Definition at line 35 of file OverlayTexture.cs.

Referenced by GetModifiedMaterial().

◆ m_NeedsToSetMaterialDirty

bool OverlayTexture.m_NeedsToSetMaterialDirty
private

Definition at line 33 of file OverlayTexture.cs.

Referenced by GetModifiedMaterial(), and Update().

◆ m_OverlayTexture

Texture2D OverlayTexture.m_OverlayTexture

Definition at line 31 of file OverlayTexture.cs.

◆ m_TextureMode

TextureMode OverlayTexture.m_TextureMode
private

Definition at line 25 of file OverlayTexture.cs.

◆ m_Verts

List<UIVertex> OverlayTexture.m_Verts = new List<UIVertex>()
private

Definition at line 37 of file OverlayTexture.cs.

Referenced by ModifyMesh().

Property Documentation

◆ colorMode

ColorMode OverlayTexture.colorMode
getset

Definition at line 55 of file OverlayTexture.cs.

56 {
57 get
58 {
59 return m_ColorMode;
60 }
61 set
62 {
63 m_ColorMode = value;
64 if (base.graphic != null)
65 {
66 base.graphic.SetVerticesDirty();
67 }
68 }
69 }
ColorMode m_ColorMode

Referenced by GetModifiedMaterial().

◆ overlayTexture

Texture2D OverlayTexture.overlayTexture
getset

Definition at line 71 of file OverlayTexture.cs.

72 {
73 get
74 {
75 return m_OverlayTexture;
76 }
77 set
78 {
79 m_OverlayTexture = value;
80 if (base.graphic != null)
81 {
82 base.graphic.SetVerticesDirty();
83 }
84 }
85 }
Texture2D m_OverlayTexture

Referenced by GetModifiedMaterial().

◆ textureMode

TextureMode OverlayTexture.textureMode
getset

Definition at line 39 of file OverlayTexture.cs.

40 {
41 get
42 {
43 return m_TextureMode;
44 }
45 set
46 {
47 m_TextureMode = value;
48 if (base.graphic != null)
49 {
50 base.graphic.SetVerticesDirty();
51 }
52 }
53 }
TextureMode m_TextureMode

Referenced by ModifyMesh().


The documentation for this class was generated from the following file: