Exemplo n.º 1
0
    public static void DrawFromPixelTexture(Texture2D to, PixelTexture from, Color col, Vector2 start)
    {
        //start is bottom left

        for (int y = 0; y < from.height; y++)
        {
            for (int x = 0; x < from.width; x++)
            {
                if (from.GetPixel(x, y).a == 0f)
                {
                    continue;
                }

                Color pixelColor = col;
                if (from.GetPixel(x, y).val < 0.45f)
                {
                    pixelColor  *= (1f - (0.5f - from.GetPixel(x, y).val));
                    pixelColor.a = 1f;
                }
                else if (from.GetPixel(x, y).val > 0.55f)
                {
                    pixelColor  *= (1f + (from.GetPixel(x, y).val - 0.5f));
                    pixelColor.a = 1f;
                }

                to.SetPixel(x + (int)start.x, y + (int)start.y, pixelColor);
            }
        }
    }
Exemplo n.º 2
0
    private void DrawShape(PixelTexture shape, int posX, int posY, string label)
    {
        GUI.Label(new Rect(posX, posY - 20, 200, 20), label, EditorStyles.boldLabel);

        for (int y = 0; y < shape.height; y++)
        {
            for (int x = 0; x < shape.width; x++)
            {
                Rect rect = new Rect(posX + pixelSize * x, posY + pixelSize * (shape.height - y - 1), pixelSize, pixelSize);

                if (shape.GetPixel(x, y).a == 0f)
                {
                    DrawBox(rect, Color.white);
                    continue;
                }

                GUI.color = PixelCharacterDrawTool.GreyColor(shape.GetPixel(x, y).val);
                GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture);
                DrawBox(rect, Color.white);
            }
        }

        DrawBox(new Rect(posX, posY, shape.width * pixelSize, shape.height * pixelSize), Color.white);
    }