Search Issue Tracker

By Design



Found in


Issue ID




Adding a polygon collider 2d on runtime via script is broken on builds



To reproduce:
1. Open attached project
2. Open scene "screen". It contains a sprite and a script that attaches a polygon collider 2d component. There is also a script that draws the outlines of the collider
3. Run the scene - the collider looks nice
4. Build and run - the collider is somewhat random and not like the sprite at all

Comments (3)

  1. kcarroll_cmm

    Jul 31, 2014 19:35

    Any traction on this? I am using Unity 4.5.2f1 and it is still a problem.

  2. joe_raised

    Apr 28, 2014 12:02

    I am having this exact same problem, but the suggested fix/work around does not work.

    I have my textures in a Resources folder.
    I have them set to Texture type 'Advanced'.
    I have Read/Write enabled.

    When I load them dynamically when testing, they work great. When they load via a build (Web, x86, Mac OSX) they all generated a seemingly random off centre PolygonCollider2D mesh.

    Here is a textures .meta file:
    fileFormatVersion: 2
    guid: 825af6a76cab540b49cd6d74a9b0c867
    serializedVersion: 2
    mipMapMode: 0
    enableMipMap: 1
    linearTexture: 0
    correctGamma: 0
    fadeOut: 0
    borderMipMap: 0
    mipMapFadeDistanceStart: 1
    mipMapFadeDistanceEnd: 3
    convertToNormalMap: 0
    externalNormalMap: 0
    heightScale: .25
    normalMapFilter: 0
    isReadable: 1
    grayScaleToAlpha: 0
    generateCubemap: 0
    seamlessCubemap: 0
    textureFormat: -1
    maxTextureSize: 1024
    filterMode: -1
    aniso: 1
    mipBias: -1
    wrapMode: 1
    nPOTScale: 0
    lightmap: 0
    compressionQuality: 50
    spriteMode: 1
    spriteExtrude: 1
    spriteMeshType: 1
    alignment: 0
    spritePivot: {x: .5, y: .5}
    spritePixelsToUnits: 100
    alphaIsTransparency: 1
    textureType: 5
    buildTargetSettings: []
    sprites: []

  3. TomasJ

    Mar 26, 2014 10:45

    In order to generate a Sprite outline, the texture must be readable. Otherwise pixel data is pushed to GPU and discarded.
    Set Read/Write Enable in the texture importer to fix this

Add comment

Log in to post comment