Example #1
0
    public Texture2D MakeTexture()
    {
        // make copies of each texture and use those instead
        // otherwise we mess up the base textures over multiple MakeTexture() calls
        Texture2D[] baseTextures = new Texture2D[teamTextures.Length];
        teamTextures.CopyTo(baseTextures, 0);

        // save the first three colors to use for teamcolors

        // color each texture
        for (int colorLevel = 0; colorLevel < baseTextures.Length; colorLevel++)
        {
            Texture2D newTexture = new Texture2D(baseTextures[colorLevel].width,
                                                 baseTextures[colorLevel].height);
            Color[] newpixels = TextureUtils.Colorize(baseTextures[colorLevel].GetPixels(),
                                                      teamColors[colorLevel]);
            newTexture.SetPixels(newpixels);
            newTexture.Apply();

            baseTextures[colorLevel] = newTexture;
        }

        Texture2D finalTexture = new Texture2D(baseTextures[0].width, baseTextures[0].height);

        finalTexture.filterMode = FilterMode.Point;
        finalTexture.SetPixels(baseTextures[0].GetPixels());
        finalTexture.Apply();

        // paste each texture onto the prior
        for (int blitLevel = 1; blitLevel < baseTextures.Length; blitLevel++)
        {
            Color[] bottomPixels = finalTexture.GetPixels();
            Color[] topPixels    = baseTextures[blitLevel].GetPixels();

            bottomPixels = TextureUtils.Paste(topPixels, bottomPixels);

            finalTexture.SetPixels(bottomPixels);
            finalTexture.Apply();
        }

        if (blurMask != null)
        {
            finalTexture.SetPixels(TextureUtils.Mask(finalTexture.GetPixels(), blurMask.GetPixels()));
            finalTexture.Apply();
        }

        if (mask != null)
        {
            finalTexture.SetPixels(TextureUtils.Mask(finalTexture.GetPixels(), mask.GetPixels()));
            finalTexture.Apply();
        }

        // copy into a new texture and return
        return(finalTexture);
    }
    Texture2D MakeTexture()
    {
        // save the first three colors to use for teamcolors


        // color each texture
        for (int colorLevel = 0; colorLevel < teamTextures.Length; colorLevel++)
        {
            Texture2D newTexture = new Texture2D(teamTextures[colorLevel].width,
                                                 teamTextures[colorLevel].height);
            Color[] newpixels = TextureUtils.Colorize(teamTextures[colorLevel].GetPixels(),
                                                      teamColors[colorLevel]);
            newTexture.SetPixels(newpixels);
            newTexture.Apply();

            teamTextures[colorLevel] = newTexture;
        }

        Texture2D finalTexture = new Texture2D(teamTextures[0].width, teamTextures[0].height);

        finalTexture.filterMode = FilterMode.Point;
        finalTexture.SetPixels(teamTextures[0].GetPixels());
        finalTexture.Apply();

        // paste each texture onto the prior
        for (int blitLevel = 1; blitLevel < teamTextures.Length; blitLevel++)
        {
            Color[] bottomPixels = finalTexture.GetPixels();
            Color[] topPixels    = teamTextures[blitLevel].GetPixels();

            bottomPixels = TextureUtils.Paste(topPixels, bottomPixels);

            finalTexture.SetPixels(bottomPixels);
            finalTexture.Apply();
        }

        if (mask != null)
        {
            finalTexture.SetPixels(TextureUtils.Mask(finalTexture.GetPixels(), mask.GetPixels()));
            finalTexture.Apply();
        }

        // copy into a new texture and return
        return(finalTexture);
    }