Exemplo n.º 1
0
    public static Texture2D SetupTexture(PixelTexture head, PixelTexture body, PixelTexture legs)
    {
        int height = head.height + body.height + legs.height;
        int width  = 0;

        if (head.width >= body.width && head.width >= legs.width)
        {
            width = head.width;
        }
        else if (body.width >= head.width && body.width >= legs.width)
        {
            width = body.width;
        }
        else
        {
            width = legs.width;
        }

        Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, false);

        texture.filterMode = FilterMode.Point;
        texture.wrapMode   = TextureWrapMode.Clamp;

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                texture.SetPixel(x, y, new Color(1f, 1f, 1f, 0f));
            }
        }

        return(texture);
    }
Exemplo n.º 2
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.º 3
0
 private static void SetVariables(PixelCharacter.BodyPart bodyPart, PixelTexture shape, string shapeName)
 {
     ShapeCreatorWindow.bodyPart  = bodyPart;
     ShapeCreatorWindow.shape     = shape;
     ShapeCreatorWindow.shapeName = shapeName;
     variablesSet = true;
 }
Exemplo n.º 4
0
 private void DrawBodyPartWithStyles(BodyPart bodyPart, Vector2 startPoint, Color skinCol)
 {
     PixelCharacterDrawTool.DrawFromPixelTexture(texture, bodyPart.shape, skinCol, startPoint);
     for (int i = 0; i < bodyPart.styleLayers.Count; i++)
     {
         if (bodyPart.styleLayers[i].drawProbability >= Random.Range(0f, 1f))
         {
             PixelTexture style = bodyPart.styleLayers[i].styles[Random.Range(0, bodyPart.styleLayers[i].styles.Count)];
             Color        col   = bodyPart.styleLayers[i].colors[Random.Range(0, bodyPart.styleLayers[i].colors.Length)];
             PixelCharacterDrawTool.DrawFromPixelTexture(texture, style, col, startPoint);
         }
     }
 }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
0
 public BodyPart(string name)
 {
     this.name   = name;
     shape       = new PixelTexture();
     styleLayers = new List <StyleLayer>();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Dispose Content
 /// </summary>
 public static void Dispose()
 {
     PixelTexture.Dispose();
 }