Skip to content

[Bug] When the map is set to infinite, the layer custom property is not set to children.  #160

@Snowdrama

Description

@Snowdrama

When using a non infinite map, the output applies the unity:layer correctly In this example my map is non infinite and when importing it works correctly setting the layer of the object with the PolygonCollider2D to the layer "Wall" as expected.
image

However when toggling the map to infinite and doing map chunks, the layer is no longer applied and the layer is instead set to Default
image

Current workaround is to copy the layer down using a custom importer.

using UnityEngine;
using SuperTiled2Unity;
using SuperTiled2Unity.Editor;

public class InfiniteTerrainLayerFix: CustomTmxImporter
{
    public override void TmxAssetImported(TmxAssetImportedArgs args)
    {
        SuperMap map = args.ImportedSuperMap;
        foreach (Transform grid in map.gameObject.transform)
        {
            foreach (Transform gridLayer in grid)
            {
                Layer setLayer = gridLayer.gameObject.layer;
                foreach(Transform chunk in gridLayer.transform)
                {
                    foreach(Transform collider in chunk.transform)
                    {
                        if(collider.GetComponent<PolygonCollider2D>() != null)
                        {
                            collider.gameObject.layer = setLayer;
                        }
                    }
                }
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions