Example #1
0
    private void ParseMap(Texture2D map)
    {
        var mapWidth  = map.width;
        var mapHeight = map.height;

        this._mapNodes = new MapNode[mapWidth, mapHeight];

        for (int x = 0; x < mapWidth; x++)
        {
            for (int y = 0; y < mapHeight; y++)
            {
                var        pixel = map.GetPixel(x, y);
                var        node  = new MapNode();
                GameObject obj   = GameObject.Instantiate(Test);

                obj.transform.SetParent(MapMasterObj.transform);
                obj.transform.position = new Vector3(x, y, 0);

                obj.GetComponent <SpriteRenderer>().color = pixel;
                obj.name = string.Format("({0}, {1}) Tile", x, y);
                node.CreateRenderer(obj);
            }
        }
    }