Esempio n. 1
0
    public void BuildTexture(GameObject go, TileMapData mapinstance, int size_X, int size_Z)
    {
        int       texWidth  = size_X * 16;
        int       texHeight = size_Z * 16;
        Texture2D mytex     = new Texture2D(texWidth, texHeight);

        for (int b = 0; b < size_Z; b++)
        {
            for (int a = 0; a < size_X; a++)
            {
                Color[] c = mapinstance.getTile(a, b, TileMapData.Location.Current).Graphic;
                //returns map_data[int x,int y]
                mytex.SetPixels(a * 16, b * 16, 16, 16, c);
            }
        }
        mytex.filterMode = FilterMode.Point;
        mytex.wrapMode   = TextureWrapMode.Clamp;
        mytex.Apply();
        MeshRenderer mesh_renderer = go.GetComponent <MeshRenderer>();

        mesh_renderer.sharedMaterials[0].mainTexture = mytex;
        Debug.Log("Done Texture!");
    }