Ejemplo n.º 1
0
    public static Color[] GetAvailableColors(PalleteType pallete)
    {
        Color[] colors = new Color[1] {
            new Color(0, 0, 0)
        };
        switch (pallete)
        {
        case PalleteType.red:
            colors = new Color[3] {
                new Color(0.8f, 0.015f, 0.06f),
                new Color(0.75f, 0.03f, 0.03f),
                new Color(0.68f, 0.07f, 0.08f)
            };
            break;

        case PalleteType.blue:
            colors = new Color[3] {
                new Color(0.05f, 0.25f, 0.95f),
                new Color(0.03f, 0.025f, 0.8f),
                new Color(0.05f, 0.05f, 0.9f)
            };
            break;

        case PalleteType.grey:
            colors = new Color[3] {
                new Color(0.7f, 0.7f, 0.7f),
                new Color(0.4f, 0.4f, 0.4f),
                new Color(0.8f, 0.8f, 0.8f)
            };
            break;

        case PalleteType.green:
            colors = new Color[3] {
                new Color(0.12f, 0.87f, 0.1f),
                new Color(0.05f, 0.43f, 0.06f),
                new Color(0.1f, 0.6f, 0.1f)
            };
            break;

        case PalleteType.sand:
            colors = new Color[3] {
                new Color(0.95f, 0.8f, 0.74f),
                new Color(0.93f, 0.8f, 0.78f),
                new Color(0.8f, 0.7f, 0.65f)
            };
            break;

        case PalleteType.teal:
            colors = new Color[3] {
                new Color(0.12f, 0.87f, 0.87f),
                new Color(0.05f, 0.72f, 0.74f),
                new Color(0.1f, 0.78f, 0.75f)
            };
            break;

        default:
            break;
        }
        return(colors);
    }
Ejemplo n.º 2
0
    public static Texture2D CreateRandomTexture(PalleteType pallete, int sizex, int sizey)
    {
        Color[] colors = GetAvailableColors(pallete);

        int textureSize = sizex * sizey;

        Color[] textureColors  = new Color[textureSize];
        int     amountOfColors = colors.Length;

        for (int i = 0; i < textureSize; i++)
        {
            int thisColor = Random.Range(0, amountOfColors);
            textureColors[i] = colors[thisColor];
        }
        Texture2D texture = new Texture2D(sizex, sizey);

        texture.SetPixels(textureColors);
        if (Mathf.Max(new int[2] {
            texture.width, texture.height
        }) > 300)
        {
            texture.filterMode = FilterMode.Bilinear;
        }
        else
        {
            texture.filterMode = FilterMode.Point;
        }
        texture.Apply();
        return(texture);
    }