UnityEditor.GradientEditor.CreateCheckerTexture C# (CSharp) Method

CreateCheckerTexture() public static method

public static CreateCheckerTexture ( int numCols, int numRows, int cellPixelWidth, Color col1, Color col2 ) : Texture2D
numCols int
numRows int
cellPixelWidth int
col1 Color
col2 Color
return UnityEngine.Texture2D
        public static Texture2D CreateCheckerTexture(int numCols, int numRows, int cellPixelWidth, Color col1, Color col2)
        {
            int height = numRows * cellPixelWidth;
            int width = numCols * cellPixelWidth;
            Texture2D textured = new Texture2D(width, height, TextureFormat.RGBA32, false) {
                hideFlags = HideFlags.HideAndDontSave
            };
            Color[] colors = new Color[width * height];
            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numCols; j++)
                {
                    for (int k = 0; k < cellPixelWidth; k++)
                    {
                        for (int m = 0; m < cellPixelWidth; m++)
                        {
                            colors[((((i * cellPixelWidth) + k) * width) + (j * cellPixelWidth)) + m] = (((i + j) % 2) != 0) ? col2 : col1;
                        }
                    }
                }
            }
            textured.SetPixels(colors);
            textured.Apply();
            return textured;
        }

Usage Example

Ejemplo n.º 1
0
 public static Texture2D GetBackgroundTexture()
 {
     if (s_BackgroundTexture == null)
     {
         s_BackgroundTexture = GradientEditor.CreateCheckerTexture(32, 4, 4, Color.white, new Color(0.7f, 0.7f, 0.7f));
     }
     return(s_BackgroundTexture);
 }
All Usage Examples Of UnityEditor.GradientEditor::CreateCheckerTexture