void DrawMap()
    {
        size = new Vector3((bottomLeft.transform.position.x - upperRight.transform.position.x), (bottomLeft.transform.position.y - upperRight.transform.position.y), (bottomLeft.transform.position.z - upperRight.transform.position.z));

        for (int i = 0; i < (int)Mathf.Abs(size.x) / gridStep; i++)
        {
            for (int j = 0; j < (int)Mathf.Abs(size.y) / gridStep; j++)
            {
                //Color color = new Color(map[i, j], map[i, j], map[i, j]);
                //Color color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f));
                Color color = ColorGradient.FullColorGradient(map[i, j], 0, tmp);

                Vector3 pos = new Vector3(bottomLeft.position.x + i * gridStep + gridStep / 2, bottomLeft.position.y + j * gridStep + gridStep / 2, 5);

                GameObject other = (GameObject)Instantiate(cube, pos, Quaternion.identity);
                other.name = map[i, j].ToString();
                other.GetComponent <Renderer>().material.color = color;
            }
        }
    }
    void Start()
    {
        mesh     = GetComponent <MeshFilter>().mesh;
        vertices = mesh.vertices;

        texture = new Texture2D(12, 12);
        GetComponent <Renderer>().material.mainTexture = texture;
        int y   = 0;
        int tmp = 0;

        while (y < texture.width)
        {
            int x = 0;
            while (x < texture.height)
            {
                Color color = ColorGradient.FullColorGradient(tmp, 0, 12 * 12);
                texture.SetPixel(x, y, color);
                ++tmp;
                ++x;
            }
            ++y;
        }
        texture.Apply();
    }
Exemple #3
0
    void CreateTexture()
    {
        if (texture == null)
        {
            texture            = new Texture2D((int)size.x / gridStep, (int)size.y / gridStep);
            texture.wrapMode   = TextureWrapMode.Clamp;
            texture.filterMode = FilterMode.Point;
        }

        if (!shitbool)
        {
            texture.filterMode = FilterMode.Point;
        }
        else
        {
            texture.filterMode = FilterMode.Bilinear;
        }
        //texture = new Texture2D(-5, -1);

        int y = 0;

        //Debug.Log("S: " + DateTime.Now.Second +":"+ DateTime.Now.Millisecond);
        while (y < texture.height)
        {
            int x = 0;
            while (x < texture.width)
            {
                Color color = Color.clear;
                switch (colorMode)
                {
                case 0:
                    color = ColorGradient.MonoChrome(map[x, y], mapMin, mapMax);
                    break;

                case 1:
                    color = ColorGradient.TwoColorGradentRG(map[x, y], mapMin, mapMax);
                    break;

                case 2:
                    color = ColorGradient.FullColorGradient(map[x, y], mapMin, mapMax);
                    break;

                case 3:
                    color = ColorGradient.FullColorBWR(map[x, y], mapMin, mapMax);
                    break;

                case 4:
                    color = ColorGradient.FullColorWBR(map[x, y], mapMin, mapMax);
                    break;

                case 5:
                    color = ColorGradient.FullColorCGY(map[x, y], mapMin, mapMax);
                    break;

                default:
                    color = ColorGradient.FullColorGradient(map[x, y], mapMin, mapMax);
                    break;
                }
                color.a = Mathf.Clamp(color.a, 0f, 0.6f);
                texture.SetPixel(x, y, color);
                ++x;
            }
            ++y;
        }
        texture.Apply();
        //Debug.Log("F: " + DateTime.Now.Second + ":" + DateTime.Now.Millisecond);
    }