public virtual void Init() { if (m_mesh == null) { CreateMesh(); } // Assign to mesh object: m_mesh.Clear(); m_mesh.vertices = m_vertices; m_mesh.uv = m_uvs; m_mesh.colors = m_colors; m_mesh.triangles = m_faces; SetWindingOrder(m_sprite.winding); // Calculate UV dimensions: if (!m_sprite.uvsInitialized) { m_sprite.InitUVs(); m_sprite.uvsInitialized = true; } m_sprite.SetBleedCompensation(m_sprite.bleedCompensation); // Build vertices: if (m_sprite.pixelPerfect) { if (m_texture == null) { if (meshRenderer.sharedMaterial != null) { m_texture = meshRenderer.sharedMaterial.GetTexture("_MainTex"); } } if (m_texture != null) { m_sprite.SetPixelToUV(m_texture); } if (m_sprite.renderCamera == null) { m_sprite.SetCamera(Camera.main); } else { m_sprite.SetCamera(m_sprite.renderCamera); } } else if (!m_sprite.hideAtStart) { m_sprite.SetSize(m_sprite.width, m_sprite.height); } m_mesh.RecalculateNormals(); // Set colors: m_sprite.SetColor(m_sprite.color); }
public virtual void Init() { if (m_sprite != null) { if (!m_sprite.Started) { m_sprite.Start(); } // Calculate UV dimensions: if (!m_sprite.uvsInitialized) { m_sprite.InitUVs(); m_sprite.uvsInitialized = true; } m_sprite.SetBleedCompensation(m_sprite.bleedCompensation); // Build vertices: if (m_sprite.pixelPerfect) { if (m_texture != null) { m_sprite.SetPixelToUV(m_texture); } if (m_sprite.renderCamera == null) { m_sprite.SetCamera(Camera.main); } else { m_sprite.SetCamera(m_sprite.renderCamera); } } else if (!m_sprite.hideAtStart) { m_sprite.SetSize(m_sprite.width, m_sprite.height); } // Set colors: m_sprite.SetColor(m_sprite.color); } }
public virtual void Init() { if (m_mesh == null) { meshFilter.sharedMesh = new Mesh(); m_mesh = meshFilter.sharedMesh; if (m_sprite.persistent) { GameObject.DontDestroyOnLoad(m_mesh); } } // Assign to mesh object: m_mesh.Clear(); m_mesh.vertices = m_vertices; m_mesh.uv = m_uvs; m_mesh.colors = m_colors; m_mesh.triangles = m_faces; SetWindingOrder(m_sprite.winding); // Calculate UV dimensions: m_sprite.InitUVs(); m_sprite.SetBleedCompensation(m_sprite.bleedCompensation); // Build vertices: if (m_sprite.pixelPerfect) { if (m_texture == null) { if (meshRenderer.sharedMaterial != null) { m_texture = meshRenderer.sharedMaterial.GetTexture("_MainTex"); } } if (m_texture != null) { m_sprite.SetPixelToUV(m_texture); } if (m_sprite.renderCamera == null) { m_sprite.SetCamera(Camera.mainCamera); } else { m_sprite.SetCamera(m_sprite.renderCamera); } } else if (!m_sprite.hideAtStart) { m_sprite.SetSize(m_sprite.width, m_sprite.height); } #if SPRITE_WANT_NORMALS m_mesh.RecalculateNormals(); #endif // Set colors: m_sprite.SetColor(m_sprite.color); }