Ejemplo n.º 1
0
    public void UpdateTexture(int x, int y)
    {
        int tile = (int)MapInfo.GetTileType(x, y);

        //Debug.Log (tile);
        tilesRow = tiles[tile];
        texture.SetPixels(x * tileResolution, y * tileResolution, tileResolution, tileResolution, tilesRow);
        texture.Apply();
    }
Ejemplo n.º 2
0
    void BuildTexture()
    {
        int       texWidth  = size_x * tileResolution;
        int       texHeight = size_z * tileResolution;
        Texture2D texture   = new Texture2D(texWidth, texHeight);

        Color[][] tiles = ChopUpTiles();

        for (int y = 0; y < size_z; y++)
        {
            for (int x = 0; x < size_x; x++)
            {
                Color[] p = tiles[MapInfo.GetTileType(x, y)];
                texture.SetPixels(x * tileResolution, y * tileResolution, tileResolution, tileResolution, p);
            }
        }

        texture.filterMode = FilterMode.Point;
        texture.wrapMode   = TextureWrapMode.Clamp;
        texture.Apply();

        MeshRenderer mesh_renderer = GetComponent <MeshRenderer>();

        Debug.Log(texture.GetInstanceID());
        mesh_renderer.sharedMaterial.mainTexture = texture;

        Debug.Log("Done Texture!");
    }