Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I access Polygon Collider points after auto-tiling, or alternatively 9-slice a set of points

Discussion in '2D' started by alesimula, Jun 4, 2020.

  1. alesimula

    alesimula

    Joined:
    Mar 27, 2019
    Posts:
    7
    My intention is to implement something similar to the auto-tiling feature for the ShadowCaster2D shape, so that I can resize the sprite renderer without having to manually resize the shadow caster shape.

    My first idea was to use an actual PolygonCollider2D, set the `points` field the same as the shadow caster points, then enable auto-tiling: this seems to generate a 9-sliced set of points, however, I have no idea how to retrieve this set as both the `points` property and the `getPath(index)` function return the non-autotiled points.

    Is there any way to return the generated set of points (even by reflection) or, alternatively, do something similar to what the PolygonCollider2D's auto-tiling does without relying on it (again, even by reflection)

    PS: I already know how to change the shadow caster points (I've done something similar here to mirror the shadowcaster); I'm only running the script in inspector mode