UnityEngine.Texture2D.SetPixel C# (CSharp) Method

SetPixel() public method

Sets pixel color at coordinates (x,y).

public SetPixel ( int x, int y, Color color ) : void
x int
y int
color Color
return void
        public void SetPixel(int x, int y, Color color)
        {
            INTERNAL_CALL_SetPixel(this, x, y, ref color);
        }

Usage Example

コード例 #1
0
        public void DoDrawTextureCircle(Texture2D tex, int cx, int cy, int r, Color col)
        {
            //Color32 _col = (Color32)col;

               int x, y, px, nx, py, ny, d;

              // Color32[] tempArray = tex.GetPixels32();

               for (x = 0; x <= r; x++)
               {
             d = (int)Mathf.Ceil(Mathf.Sqrt(r * r - x * x));
             for (y = 0; y <= d; y++)
             {
              px = cx + x;
              nx = cx - x;
              py = cy + y;
              ny = cy - y;

             tex.SetPixel(px, py, col);
              	tex.SetPixel(nx, py, col);

             	 tex.SetPixel(px, ny, col);
             	 tex.SetPixel(nx, ny, col);

             // tempArray[py*1024 + px] = _col;
             // tempArray[py*1024 + nx] = _col;
             // tempArray[ny*1024 + px] = _col;
               //   tempArray[ny*1024 + nx] = _col;
             }
               }
             //  tex.SetPixels32(tempArray);
               tex.Apply ();
        }
All Usage Examples Of UnityEngine.Texture2D::SetPixel