8 using System.Collections;
16 public class SpriteMesh_Managed : ISpriteMesh, IEZLinkedListItem<SpriteMesh_Managed>
20 protected bool hidden;
27 public SpriteMesh_Managed m_next;
28 public SpriteMesh_Managed m_prev;
31 protected Vector3[] m_vertices =
new Vector3[4];
32 protected Vector2[] m_uvs =
new Vector2[4];
33 protected Vector2[] m_uvs2 =
new Vector2[4];
34 protected bool m_useUV2 =
false;
35 protected Material m_material;
36 protected Texture m_texture;
39 protected Vector3[] meshVerts;
42 protected Vector2[] meshUVs;
43 protected Vector2[] meshUVs2;
46 protected Color[] meshColors;
63 public void SetBuffers(Vector3[] verts, Vector2[] uvs, Vector2[] uvs2, Color[] cols)
79 get {
return m_manager; }
84 m_material = m_manager.renderer.sharedMaterial;
86 if(m_material != null)
87 m_texture = m_material.GetTexture(
"_MainTex");
93 get {
return m_sprite; }
98 UpdateColors(m_sprite.color);
102 public virtual Texture texture
104 get {
return m_texture; }
107 public virtual Material material
109 get {
return m_material; }
112 public virtual Vector3[] vertices
114 get {
return m_vertices; }
117 public virtual Vector2[] uvs
119 get {
return m_uvs; }
122 public virtual Vector2[] uvs2
124 get {
return m_uvs2; }
127 public virtual bool UseUV2
129 get {
return m_useUV2; }
130 set { m_useUV2 = value; }
133 public virtual void Init()
135 if (!m_sprite.Started)
139 if (!m_sprite.uvsInitialized)
142 m_sprite.uvsInitialized =
true;
145 m_sprite.SetBleedCompensation(m_sprite.bleedCompensation);
148 if (m_sprite.pixelPerfect)
150 if (m_texture != null)
152 m_sprite.SetPixelToUV(m_texture);
155 if (m_sprite.renderCamera == null)
156 m_sprite.SetCamera(Camera.main);
158 m_sprite.SetCamera(m_sprite.renderCamera);
160 else if(!m_sprite.hideAtStart)
161 m_sprite.SetSize(m_sprite.width, m_sprite.height);
164 m_sprite.SetColor(m_sprite.color);
167 public virtual void UpdateVerts()
176 meshVerts[mv1] = m_vertices[0];
177 meshVerts[mv2] = m_vertices[1];
178 meshVerts[mv3] = m_vertices[2];
179 meshVerts[mv4] = m_vertices[3];
181 meshVerts[mv1].x = m_vertices[0].x; meshVerts[mv1].y = m_vertices[0].y; meshVerts[mv1].z = m_vertices[0].z;
182 meshVerts[mv2].x = m_vertices[1].x; meshVerts[mv2].y = m_vertices[1].y; meshVerts[mv2].z = m_vertices[1].z;
183 meshVerts[mv3].x = m_vertices[2].x; meshVerts[mv3].y = m_vertices[2].y; meshVerts[mv3].z = m_vertices[2].z;
184 meshVerts[mv4].x = m_vertices[3].x; meshVerts[mv4].y = m_vertices[3].y; meshVerts[mv4].z = m_vertices[3].z;
187 m_manager.UpdatePositions();
190 public virtual void UpdateUVs()
193 meshUVs[uv1] = uvs[0];
194 meshUVs[uv2] = uvs[1];
195 meshUVs[uv3] = uvs[2];
196 meshUVs[uv4] = uvs[3];
198 meshUVs[uv1].x = uvs[0].x; meshUVs[uv1].y = uvs[0].y;
199 meshUVs[uv2].x = uvs[1].x; meshUVs[uv2].y = uvs[1].y;
200 meshUVs[uv3].x = uvs[2].x; meshUVs[uv3].y = uvs[2].y;
201 meshUVs[uv4].x = uvs[3].x; meshUVs[uv4].y = uvs[3].y;
207 meshUVs2[uv1] = uvs2[0];
208 meshUVs2[uv2] = uvs2[1];
209 meshUVs2[uv3] = uvs2[2];
210 meshUVs2[uv4] = uvs2[3];
212 meshUVs2[uv1].x = uvs2[0].x; meshUVs2[uv1].y = uvs2[0].y;
213 meshUVs2[uv2].x = uvs2[1].x; meshUVs2[uv2].y = uvs2[1].y;
214 meshUVs2[uv3].x = uvs2[2].x; meshUVs2[uv3].y = uvs2[2].y;
215 meshUVs2[uv4].x = uvs2[3].x; meshUVs2[uv4].y = uvs2[3].y;
219 m_manager.UpdateUVs();
222 public virtual void UpdateColors(Color color)
224 meshColors[cv1] = color;
225 meshColors[cv2] = color;
226 meshColors[cv3] = color;
227 meshColors[cv4] = color;
229 m_manager.UpdateColors();
232 public virtual void Hide(
bool tf)
236 m_vertices[0] = Vector3.zero;
237 m_vertices[1] = Vector3.zero;
238 m_vertices[2] = Vector3.zero;
239 m_vertices[3] = Vector3.zero;
246 if (m_sprite.pixelPerfect)
249 m_sprite.SetSize(m_sprite.width, m_sprite.height);
253 public virtual bool IsHidden()
258 public SpriteMesh_Managed prev
260 get {
return m_prev; }
261 set { m_prev = value; }
264 public SpriteMesh_Managed next
266 get {
return m_next; }
267 set { m_next = value; }
The root class of all sprites. Does not assume any animation capabilities or atlas packing...
Allows multiple sprites to be combined into a single mesh. Sprites are transformed using bones which ...