Search Unity

is there any way to disable sprite outline generation?

Discussion in '2D' started by benblo, Jun 21, 2016.

  1. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    I'm talking about this:
    Code (CSharp):
    1.   spriteSheet:
    2.     sprites:
    3.     - name: bla
    4.       rect:
    5.         serializedVersion: 2
    6.         x: 542
    7.         y: 384
    8.         width: 69
    9.         height: 161
    10.       alignment: 0
    11.       pivot: {x: 0.5, y: 0.5}
    12.       border: {x: 0, y: 0, z: 0, w: 0}
    13.       outline:
    14.       - - {x: 0.5, y: 77.5}
    15.         - {x: -4.5, y: 80.5}
    16.         - {x: -21.5, y: 80.5}
    17.         - {x: -27.5, y: 72.5}
    18.         - {x: -34.5, y: 27.5}
    19.         - {x: -34.5, y: -70.5}
    20.         - {x: -8.5, y: -80.5}
    21.         - {x: 25.5, y: -80.5}
    22.         - {x: 34.5, y: -75.5}
    23.         - {x: 34.5, y: -48.5}
    24.         - {x: 33.5, y: -38.5}
    25.  
    AFAICT, this data is not useful at the moment (only used for polygon sprite and for future use), but the noise in the meta file is a big nuisance. Plus, we're doing some fancing processing at import-time that causes the generated outline to be different across machines (which is not really good, but not our biggest issue).

    I've tried to hack around it by reflecting the SpriteEditorWindow and injecting my own outline at import-time using an AssetPostprocessor:
    Code (CSharp):
    1.         void clearOutline()
    2.         {
    3.             Log("clearOutline");
    4.             var importerSO = new SerializedObject(assetImporter);
    5.  
    6.             var propOutline = importerSO.FindProperty("m_SpriteSheet.m_Outline");
    7.             propOutline.ClearArray();
    8.  
    9.             var propSpritesheet = importerSO.FindProperty("m_SpriteSheet.m_Sprites");
    10.             for (int i = 0; i < propSpritesheet.arraySize; i++)
    11.             {
    12.                 var propSprite = propSpritesheet.GetArrayElementAtIndex(i);
    13.                 var propSpriteOutline = propSprite.FindPropertyRelative("m_Outline");
    14.                 propSpriteOutline.ClearArray();
    15.                 //propSpriteOutline.InsertArrayElementAtIndex(0);
    16.                 Log("clearOutline " + i);
    17.             }
    18.  
    19.             importerSO.ApplyModifiedProperties();
    20.         }
    21.  
    ... no luck.