Ejemplo n.º 1
0
        /// ======================================================================================================================================================================
        /// <summary>
        /// Fixs the tile map.
        /// </summary>
        /// ======================================================================================================================================================================
        public static void FixTileMap( RTStudio.TileMap targetTileMap )
        {
            if ( targetTileMap.layers == null || targetTileMap == null )
                return;

            Undo.RecordObject(targetTileMap, null);

            foreach ( RTStudio.Layer layer in targetTileMap.layers )
            {
                //Force the layer to 0 0 0
                layer.transform.position = Vector3.zero;

                for( int i = 0; i < targetTileMap.mapDimensions.x; i++)
                {
                    for( int j = 0; j < targetTileMap.mapDimensions.y; j++)
                    {

                        int tileIndex = (int)(i + targetTileMap.mapDimensions.x * j);
                        if ( tileIndex < layer.tiles.Length && layer.tiles[ (int)(tileIndex) ] != null )
                        {
                            Undo.RecordObject(layer.tiles[ (int)(tileIndex) ], null);
                            layer.tiles[ (int)(tileIndex) ].transform.localPosition = targetTileMap.GetPosition(tileIndex);
                        }
                    }
                }
            }
        }