// Adds a sprite to the manager at the location and rotation of the client // GameObject and with its transform. Returns a reference to the new sprite // Width and height are in world space units // leftPixelX and bottomPixelY- the bottom-left position of the desired portion of the texture, in pixels // pixelWidth and pixelHeight - the dimensions of the desired portion of the texture, in pixels public GUISprite AddSprite(GameObject client, int width, int height, float depth, Vector2 LLUV) { int spriteIndex; Vector2 lowerLeftUV = PixelCoordToUVCoord((int)LLUV.x, (int)LLUV.y); Vector2 UVDimensions = PixelSpaceToUVSpace(width, height); // Get an available sprite: if (availableBlocks.Count < 1) { // If we're out of available sprites, allocate some more. EnlargeArrays(allocBlockSize); } // Use a sprite from the list of available blocks: spriteIndex = ((GUISprite)availableBlocks[0]).index; availableBlocks.RemoveAt(0); // Now that we're using this one, remove it from the available list // Assign the new sprite: GUISprite newSprite = sprites[spriteIndex]; newSprite.client = client; newSprite.depth = depth; newSprite.lowerLeftUV = LLUV; newSprite.uvDimensions = UVDimensions; switch (plane) { case SPRITE_PLANE.XY: newSprite.SetSizeXY(width, height); break; case SPRITE_PLANE.XZ: newSprite.SetSizeXZ(width, height); break; case SPRITE_PLANE.YZ: newSprite.SetSizeYZ(width, height); break; default: newSprite.SetSizeXY(width, height); break; } // Save this to an active list now that it is in-use: //activeBlocks.Add(newSprite); AddToActiveList(newSprite); // Setup the UVs: UVs[newSprite.uv1] = lowerLeftUV + Vector2.up * UVDimensions.y; // Upper-left UVs[newSprite.uv2] = lowerLeftUV; // Lower-left UVs[newSprite.uv3] = lowerLeftUV + Vector2.right * UVDimensions.x; // Lower-right UVs[newSprite.uv4] = lowerLeftUV + UVDimensions; // Upper-right // Set our flags: vertsChanged = true; uvsChanged = true; return(newSprite); }
protected override void OnInitialize() { this.buttonMeshRenderer = base.GetComponent <MeshRenderer>(); BoxCollider component = base.GetComponent <BoxCollider>(); GUISprite component2 = base.GetComponent <GUISprite>(); component2.SetBoardSize(component.size.x, component.size.y); }
// Informs the SpriteManager that some vertices have changed position // and the mesh needs to be reconstructed accordingly public void UpdatePositions(GUISprite sprite) { vertices[sprite.mv1] = sprite.clientTransform.TransformPoint(sprite.v1); vertices[sprite.mv2] = sprite.clientTransform.TransformPoint(sprite.v2); vertices[sprite.mv3] = sprite.clientTransform.TransformPoint(sprite.v3); vertices[sprite.mv4] = sprite.clientTransform.TransformPoint(sprite.v4); vertsChanged = true; }
// Updates the UVs of the specified sprite and copies the new values // into the mesh object. public void UpdateUV(GUISprite sprite) { UVs[sprite.uv1] = sprite.lowerLeftUV + Vector2.up * sprite.uvDimensions.y; // Upper-left UVs[sprite.uv2] = sprite.lowerLeftUV; // Lower-left UVs[sprite.uv3] = sprite.lowerLeftUV + Vector2.right * sprite.uvDimensions.x; // Lower-right UVs[sprite.uv4] = sprite.lowerLeftUV + sprite.uvDimensions; // Upper-right uvsChanged = true; }
// Updates the color values of the specified sprite and copies the // new values into the mesh object. public void UpdateColors(GUISprite sprite) { colors[sprite.cv1] = sprite.color; colors[sprite.cv2] = sprite.color; colors[sprite.cv3] = sprite.color; colors[sprite.cv4] = sprite.color; colorsChanged = true; }
// Resorts the active sprite list and rebuids the triangles array public void SortActiveList(GUISprite sprite) { //Get current sprite location int CurLoc = activeBlocks.IndexOf(sprite); //Sort active list int Index = 0; int TmpIndex = 0; int NumItems = activeBlocks.Count; GUISprite tmpSprite; for (Index = 1; Index < NumItems; Index++) { tmpSprite = (GUISprite)activeBlocks[Index]; TmpIndex = Index; while ((TmpIndex > 0) && (((GUISprite)activeBlocks[TmpIndex - 1]).depth < tmpSprite.depth)) { activeBlocks[TmpIndex] = activeBlocks[TmpIndex - 1]; TmpIndex = TmpIndex - 1; } activeBlocks[TmpIndex] = tmpSprite; } //Get new sprite location int NewLoc = activeBlocks.IndexOf(sprite); //Do nothing if sort order didn't change if (NewLoc == CurLoc) { return; } int StartIdx = 0; int EndIdx = 0; //Set start and end index if (NewLoc > CurLoc) { StartIdx = CurLoc; EndIdx = NewLoc; } else { StartIdx = NewLoc; EndIdx = CurLoc; } //Rebuild tris from current to new location RebuildTris(StartIdx, EndIdx); trisChanged = true; }
public void HideSprite(GUISprite sprite) { vertices[sprite.mv1] = Vector3.zero; vertices[sprite.mv2] = Vector3.zero; vertices[sprite.mv3] = Vector3.zero; vertices[sprite.mv4] = Vector3.zero; sprite.hidden = true; vertsChanged = true; }
// Updates the vertices of a sprite such that it is oriented // more or less toward the camera public void TransformBillboarded(GUISprite sprite) { Vector3 pos = sprite.clientTransform.position; Transform t = Camera.main.transform; vertices[sprite.mv1] = pos + t.TransformDirection(sprite.v1); vertices[sprite.mv2] = pos + t.TransformDirection(sprite.v2); vertices[sprite.mv3] = pos + t.TransformDirection(sprite.v3); vertices[sprite.mv4] = pos + t.TransformDirection(sprite.v4); vertsChanged = true; }
//Initialize Quad object public void InitQuad(GUIQuadMgr pManager) { //Set refernce to parent quad manager pGUIQuadMgr = pManager; //Get pointer to GUI manager ptrGUIMgr = (GUIManager)GameObject.Find("GUI").GetComponent(typeof(GUIManager)); //Copy position variables to transform NormalizeToScreen(); //Copy rotation variables to transform transform.localEulerAngles = mRotation; //Copy scale variables to transform transform.localScale = new Vector3(mScale.x, mScale.y, 1f); //Set layer gameObject.layer = pGUIQuadMgr.gameObject.layer; //Add sprite to manager if enabled mpGUISprite = pGUIQuadMgr.AddSprite(gameObject, mWidth, mHeight, mDepth, mUV); //Set color this.Tint = mColor; //Use default collider size if none is set. We don't want zero sized colliders. if (mColliderSize.x == 0) { //User width as default size mColliderSize.x = mWidth; } if (mColliderSize.y == 0) { //User height as default size mColliderSize.y = mHeight; } //Create hit area if needed switch (mCollider) { case ColliderType.Square: gameObject.AddComponent("BoxCollider"); break; case ColliderType.Circle: gameObject.AddComponent("SphereCollider"); break; case ColliderType.None: break; } //Set hidden this.Visible = mVisible; }
public void ShowSprite(GUISprite sprite) { // Only show the sprite if it has a client: if (sprite.client == null) { return; } sprite.hidden = false; // Update the vertices: sprite.Transform(); vertsChanged = true; }
private void UpdateChildren() { List <GUISprite> sprites = new List <GUISprite>(); foreach (Transform child in this.transform) { GUISprite sprite = child.GetComponent <GUISprite>(); if (sprite != null) { sprites.Add(sprite); } } childSprite = sprites.ToArray(); //childSprite = this.gameObject.GetComponentsInChildren<GUISprite>(); }
public GUIButton(GUISprite sprite) : base(sprite) { pText= "BUTTON"; pHoverTexture= pTexture; pPressedTexture= pTexture; pDisabledTexture= pTexture; pHoverColor= new Color(255, 128, 0); pPressedColor= new Color(0, 128, 255); if(pSprite!= null) { pTexBounds= pSprite.textureBounds; pHoverTexBounds= pSprite.textureBounds; pPressedTexBounds= pSprite.textureBounds; pDisabledTexBounds= pSprite.textureBounds; } else { pTexBounds= new Rectangle(0f, 0f, 1f, 1f); pHoverTexBounds= new Rectangle(0f, 0f, 1f, 1f); pPressedTexBounds= new Rectangle(0f, 0f, 1f, 1f); pDisabledTexBounds= new Rectangle(0f, 0f, 1f, 1f); } bEText= false; bETexHover= false; bETexPressed= false; bETexDisabled= false; bEFgColor= false; bEHoverColor= false; bEPressedColor= false; bEHoverTexBounds= false; bEPressedTexBounds= false; bEDisabledTexBounds= false; e_text= null; e_texHover= null; e_texPressed= null; e_texDisabled= null; e_fgColor= null; e_hoverColor= null; e_pressedColor= null; e_hoverTexBounds= null; e_pressedTexBounds= null; e_disabledTexBounds= null; }
// Add a reference to the sprite into the active blocks array list // This list is sorted and the tris array rebuilt protected void AddToActiveList(GUISprite sprite) { //Calculate pointer to tris array int TrisIdx = activeBlocks.Count * 6; //Update triangle pointers in sprite sprite.tv1 = TrisIdx + 0; sprite.tv2 = TrisIdx + 1; sprite.tv3 = TrisIdx + 2; sprite.tv4 = TrisIdx + 3; sprite.tv5 = TrisIdx + 4; sprite.tv6 = TrisIdx + 5; //Copy vertices to triangle list if (winding == WINDING_ORDER.CCW) { // Counter-clockwise winding triIndices[TrisIdx + 0] = sprite.mv1; triIndices[TrisIdx + 1] = sprite.mv2; triIndices[TrisIdx + 2] = sprite.mv4; triIndices[TrisIdx + 3] = sprite.mv4; triIndices[TrisIdx + 4] = sprite.mv2; triIndices[TrisIdx + 5] = sprite.mv3; } else { // Clockwise winding triIndices[TrisIdx + 0] = sprite.mv1; triIndices[TrisIdx + 1] = sprite.mv4; triIndices[TrisIdx + 2] = sprite.mv2; triIndices[TrisIdx + 3] = sprite.mv4; triIndices[TrisIdx + 4] = sprite.mv3; triIndices[TrisIdx + 5] = sprite.mv2; } //Insert sprite at the end of the list activeBlocks.Add(sprite); //Sort array list SortActiveList(sprite); trisChanged = true; }
// Remove a reference to the sprite from the active blocks array list // This tris array is rebuilt protected void RemoveFromActiveList(GUISprite sprite) { //Get start point in arraylist int StartIdx = activeBlocks.IndexOf(sprite); //Remove sprite activeBlocks.Remove(sprite); //Rebuild tris array RebuildTris(StartIdx, (activeBlocks.Count - 1)); //Clear the rest of the triangle array int TrisIdx = 0; for (TrisIdx = (activeBlocks.Count * 6); TrisIdx < triIndices.Length; TrisIdx++) { triIndices[TrisIdx] = 0; } trisChanged = true; }
public void RemoveSprite(GUISprite sprite) { sprite.SetSizeXY(0, 0); sprite.v1 = Vector3.zero; sprite.v2 = Vector3.zero; sprite.v3 = Vector3.zero; sprite.v4 = Vector3.zero; vertices[sprite.mv1] = sprite.v1; vertices[sprite.mv2] = sprite.v2; vertices[sprite.mv3] = sprite.v3; vertices[sprite.mv4] = sprite.v4; sprite.client = null; availableBlocks.Add(sprite); // Remove the sprite from the active list //activeBlocks.Remove(sprite); RemoveFromActiveList(sprite); vertsChanged = true; }
public void RemoveSprite(GUISprite sprite) { sprite.SetSizeXY(0,0); sprite.v1 = Vector3.zero; sprite.v2 = Vector3.zero; sprite.v3 = Vector3.zero; sprite.v4 = Vector3.zero; vertices[sprite.mv1] = sprite.v1; vertices[sprite.mv2] = sprite.v2; vertices[sprite.mv3] = sprite.v3; vertices[sprite.mv4] = sprite.v4; sprite.client = null; availableBlocks.Add(sprite); // Remove the sprite from the active list //activeBlocks.Remove(sprite); RemoveFromActiveList(sprite); vertsChanged = true; }
public void ShowSprite(GUISprite sprite) { // Only show the sprite if it has a client: if(sprite.client == null) { return; } sprite.hidden = false; // Update the vertices: sprite.Transform(); vertsChanged = true; }
// Updates the vertices of a sprite based on the transform // of its client GameObject public void Transform(GUISprite sprite) { sprite.Transform(); vertsChanged = true; }
// Resorts the active sprite list and rebuids the triangles array public void SortActiveList(GUISprite sprite) { //Get current sprite location int CurLoc = activeBlocks.IndexOf(sprite); //Sort active list int Index = 0; int TmpIndex = 0; int NumItems = activeBlocks.Count; GUISprite tmpSprite; for(Index=1;Index<NumItems;Index++) { tmpSprite = (GUISprite) activeBlocks[Index]; TmpIndex = Index; while( (TmpIndex > 0) && (((GUISprite)activeBlocks[TmpIndex-1]).depth < tmpSprite.depth) ) { activeBlocks[TmpIndex] = activeBlocks[TmpIndex-1]; TmpIndex = TmpIndex - 1; } activeBlocks[TmpIndex] = tmpSprite; } //Get new sprite location int NewLoc = activeBlocks.IndexOf(sprite); //Do nothing if sort order didn't change if (NewLoc == CurLoc) { return; } int StartIdx = 0; int EndIdx = 0; //Set start and end index if (NewLoc > CurLoc) { StartIdx = CurLoc; EndIdx = NewLoc; } else { StartIdx = NewLoc; EndIdx = CurLoc; } //Rebuild tris from current to new location RebuildTris(StartIdx, EndIdx); trisChanged = true; }
// Add a reference to the sprite into the active blocks array list // This list is sorted and the tris array rebuilt protected void AddToActiveList(GUISprite sprite) { //Calculate pointer to tris array int TrisIdx = activeBlocks.Count * 6; //Update triangle pointers in sprite sprite.tv1 = TrisIdx + 0; sprite.tv2 = TrisIdx + 1; sprite.tv3 = TrisIdx + 2; sprite.tv4 = TrisIdx + 3; sprite.tv5 = TrisIdx + 4; sprite.tv6 = TrisIdx + 5; //Copy vertices to triangle list if(winding == WINDING_ORDER.CCW) { // Counter-clockwise winding triIndices[TrisIdx + 0] = sprite.mv1; triIndices[TrisIdx + 1] = sprite.mv2; triIndices[TrisIdx + 2] = sprite.mv4; triIndices[TrisIdx + 3] = sprite.mv4; triIndices[TrisIdx + 4] = sprite.mv2; triIndices[TrisIdx + 5] = sprite.mv3; } else { // Clockwise winding triIndices[TrisIdx + 0] = sprite.mv1; triIndices[TrisIdx + 1] = sprite.mv4; triIndices[TrisIdx + 2] = sprite.mv2; triIndices[TrisIdx + 3] = sprite.mv4; triIndices[TrisIdx + 4] = sprite.mv3; triIndices[TrisIdx + 5] = sprite.mv2; } //Insert sprite at the end of the list activeBlocks.Add(sprite); //Sort array list SortActiveList(sprite); trisChanged = true; }
//Initialize Quad object public void InitQuad(GUIQuadMgr pManager) { //Set refernce to parent quad manager pGUIQuadMgr = pManager; //Get pointer to GUI manager ptrGUIMgr = (GUIManager) GameObject.Find("GUI").GetComponent(typeof(GUIManager)); //Copy position variables to transform NormalizeToScreen(); //Copy rotation variables to transform transform.localEulerAngles = mRotation; //Copy scale variables to transform transform.localScale = new Vector3(mScale.x, mScale.y, 1f); //Add sprite to manager if enabled mpGUISprite = pGUIQuadMgr.AddSprite(gameObject, mWidth, mHeight, mDepth, mUV); //Set color this.Tint = mColor; //Use default collider size if none is set. We don't want zero sized colliders. if (mColliderSize.x == 0) { //User width as default size mColliderSize.x = mWidth; } if (mColliderSize.y == 0) { //User height as default size mColliderSize.y = mHeight; } //Create hit area if needed switch (mCollider) { case ColliderType.Square: gameObject.AddComponent("BoxCollider"); break; case ColliderType.Circle: gameObject.AddComponent("SphereCollider"); break; case ColliderType.None: break; } //Set hidden this.Visible = mVisible; }
// Enlarges the sprite array by the specified count and also resizes // the UV and vertex arrays by the necessary corresponding amount. // Returns the index of the first newly allocated element // (ex: if the sprite array was already 10 elements long and is // enlarged by 10 elements resulting in a total length of 20, // EnlargeArrays() will return 10, indicating that element 10 is the // first of the newly allocated elements.) protected int EnlargeArrays(int count) { int firstNewElement; if (sprites == null) { InitArrays(); firstNewElement = 0; count = count - 1; // Allocate one less since InitArrays already allocated one sprite for us } else { firstNewElement = sprites.Length; } // Resize sprite array: GUISprite[] tempSprites = sprites; sprites = new GUISprite[sprites.Length + count]; tempSprites.CopyTo(sprites, 0); // Vertices: Vector3[] tempVerts = vertices; vertices = new Vector3[vertices.Length + count * 4]; tempVerts.CopyTo(vertices, 0); // UVs: Vector2[] tempUVs = UVs; UVs = new Vector2[UVs.Length + count * 4]; tempUVs.CopyTo(UVs, 0); // Colors: Color[] tempColors = colors; colors = new Color[colors.Length + count * 4]; tempColors.CopyTo(colors, 0); // Triangle indices: int[] tempTris = triIndices; triIndices = new int[triIndices.Length + count * 6]; tempTris.CopyTo(triIndices, 0); // Setup the newly-added sprites and Add them to the list of available // sprite blocks. Also initialize the triangle indices while we're at it: for (int i = firstNewElement; i < sprites.Length; ++i) { // Create and setup sprite: sprites[i] = new GUISprite(); sprites[i].index = i; sprites[i].manager = this; // Setup indices of the sprite's vertices in the vertex buffer: sprites[i].mv1 = i * 4 + 0; sprites[i].mv2 = i * 4 + 1; sprites[i].mv3 = i * 4 + 2; sprites[i].mv4 = i * 4 + 3; // Setup the indices of the sprite's UV entries in the UV buffer: sprites[i].uv1 = i * 4 + 0; sprites[i].uv2 = i * 4 + 1; sprites[i].uv3 = i * 4 + 2; sprites[i].uv4 = i * 4 + 3; // Setup the indices to the color values: sprites[i].cv1 = i * 4 + 0; sprites[i].cv2 = i * 4 + 1; sprites[i].cv3 = i * 4 + 2; sprites[i].cv4 = i * 4 + 3; // Setup the default color: sprites[i].color = Color.white; // Add as an available sprite: availableBlocks.Add(sprites[i]); /* Setup the triangle indices: * sprites[i].tv1 = i * 6 + 0; * sprites[i].tv2 = i * 6 + 1; * sprites[i].tv3 = i * 6 + 2; * sprites[i].tv4 = i * 6 + 3; * sprites[i].tv5 = i * 6 + 4; * sprites[i].tv6 = i * 6 + 5; * if(winding == WINDING_ORDER.CCW) * { // Counter-clockwise winding * triIndices[i * 6 + 0] = i * 4 + 0; // 0_ 2 0 ___ 3 * triIndices[i * 6 + 1] = i * 4 + 1; // | / Verts: | /| * triIndices[i * 6 + 2] = i * 4 + 3; // 1|/ 1|/__|2 * * triIndices[i * 6 + 3] = i * 4 + 3; // 3 * triIndices[i * 6 + 4] = i * 4 + 1; // /| * triIndices[i * 6 + 5] = i * 4 + 2; // 4/_|5 * } * else * { // Clockwise winding * triIndices[i * 6 + 0] = i * 4 + 0; // 0_ 1 0 ___ 3 * triIndices[i * 6 + 1] = i * 4 + 3; // | / Verts: | /| * triIndices[i * 6 + 2] = i * 4 + 1; // 2|/ 1|/__|2 * * triIndices[i * 6 + 3] = i * 4 + 3; // 3 * triIndices[i * 6 + 4] = i * 4 + 2; // /| * triIndices[i * 6 + 5] = i * 4 + 1; // 5/_|4 * }*/ } //Flip flags to copy new data to mesh meshChanged = true; return(firstNewElement); }
// Enlarges the sprite array by the specified count and also resizes // the UV and vertex arrays by the necessary corresponding amount. // Returns the index of the first newly allocated element // (ex: if the sprite array was already 10 elements long and is // enlarged by 10 elements resulting in a total length of 20, // EnlargeArrays() will return 10, indicating that element 10 is the // first of the newly allocated elements.) protected int EnlargeArrays(int count) { int firstNewElement; if (sprites == null) { InitArrays(); firstNewElement = 0; count = count - 1; // Allocate one less since InitArrays already allocated one sprite for us } else { firstNewElement = sprites.Length; } // Resize sprite array: GUISprite[] tempSprites = sprites; sprites = new GUISprite[sprites.Length + count]; tempSprites.CopyTo(sprites, 0); // Vertices: Vector3[] tempVerts = vertices; vertices = new Vector3[vertices.Length + count*4]; tempVerts.CopyTo(vertices, 0); // UVs: Vector2[] tempUVs = UVs; UVs = new Vector2[UVs.Length + count*4]; tempUVs.CopyTo(UVs, 0); // Colors: Color[] tempColors = colors; colors = new Color[colors.Length + count * 4]; tempColors.CopyTo(colors, 0); // Triangle indices: int[] tempTris = triIndices; triIndices = new int[triIndices.Length + count*6]; tempTris.CopyTo(triIndices, 0); // Setup the newly-added sprites and Add them to the list of available // sprite blocks. Also initialize the triangle indices while we're at it: for (int i = firstNewElement; i < sprites.Length; ++i) { // Create and setup sprite: sprites[i] = new GUISprite(); sprites[i].index = i; sprites[i].manager = this; // Setup indices of the sprite's vertices in the vertex buffer: sprites[i].mv1 = i * 4 + 0; sprites[i].mv2 = i * 4 + 1; sprites[i].mv3 = i * 4 + 2; sprites[i].mv4 = i * 4 + 3; // Setup the indices of the sprite's UV entries in the UV buffer: sprites[i].uv1 = i * 4 + 0; sprites[i].uv2 = i * 4 + 1; sprites[i].uv3 = i * 4 + 2; sprites[i].uv4 = i * 4 + 3; // Setup the indices to the color values: sprites[i].cv1 = i * 4 + 0; sprites[i].cv2 = i * 4 + 1; sprites[i].cv3 = i * 4 + 2; sprites[i].cv4 = i * 4 + 3; // Setup the default color: sprites[i].color = Color.white; // Add as an available sprite: availableBlocks.Add(sprites[i]); /* Setup the triangle indices: sprites[i].tv1 = i * 6 + 0; sprites[i].tv2 = i * 6 + 1; sprites[i].tv3 = i * 6 + 2; sprites[i].tv4 = i * 6 + 3; sprites[i].tv5 = i * 6 + 4; sprites[i].tv6 = i * 6 + 5; if(winding == WINDING_ORDER.CCW) { // Counter-clockwise winding triIndices[i * 6 + 0] = i * 4 + 0; // 0_ 2 0 ___ 3 triIndices[i * 6 + 1] = i * 4 + 1; // | / Verts: | /| triIndices[i * 6 + 2] = i * 4 + 3; // 1|/ 1|/__|2 triIndices[i * 6 + 3] = i * 4 + 3; // 3 triIndices[i * 6 + 4] = i * 4 + 1; // /| triIndices[i * 6 + 5] = i * 4 + 2; // 4/_|5 } else { // Clockwise winding triIndices[i * 6 + 0] = i * 4 + 0; // 0_ 1 0 ___ 3 triIndices[i * 6 + 1] = i * 4 + 3; // | / Verts: | /| triIndices[i * 6 + 2] = i * 4 + 1; // 2|/ 1|/__|2 triIndices[i * 6 + 3] = i * 4 + 3; // 3 triIndices[i * 6 + 4] = i * 4 + 2; // /| triIndices[i * 6 + 5] = i * 4 + 1; // 5/_|4 }*/ } //Flip flags to copy new data to mesh meshChanged = true; return firstNewElement; }
public GUIPanel() : base() { pSprite= new GUISprite(); }
// Remove a reference to the sprite from the active blocks array list // This tris array is rebuilt protected void RemoveFromActiveList(GUISprite sprite) { //Get start point in arraylist int StartIdx = activeBlocks.IndexOf(sprite); //Remove sprite activeBlocks.Remove(sprite); //Rebuild tris array RebuildTris(StartIdx, (activeBlocks.Count - 1)); //Clear the rest of the triangle array int TrisIdx = 0; for (TrisIdx = (activeBlocks.Count * 6);TrisIdx<triIndices.Length;TrisIdx++) { triIndices[TrisIdx] = 0; } trisChanged = true; }