SixWays / UnityShaderStripper

Modular utilities for shader stripping to drastically improve Unity build times
MIT License
351 stars 42 forks source link

Fix parsing of entries with multi-line object references #11

Open Grimeh opened 4 months ago

Grimeh commented 4 months ago

At some point Unity started breaking inline objects onto multiple lines (presumedly once they reach a certain line length). This causes the parser to incorrectly begin parsing on the variants: line instead of the desired - keywords: line of the first element of the variants array.

This fixes that by detecting when the shader asset reference spans multiple lines (by looking for an increase in indentation) and skips forward an extra line if that is the case.

Example of multi-line inline object reference:

  - first: {fileID: -6465566751694194690, guid: 750e95cd9826dc046a8b87ea0c15919e,
      type: 3}
    second:
      variants:
      - keywords: 
        passType: 8
      - keywords: _ADDITIONAL_LIGHTS
        passType: 13
      - keywords: _ADDITIONAL_LIGHTS _SCREEN_SPACE_OCCLUSION
        passType: 13
      - keywords: _ADDITIONAL_LIGHTS _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT
        passType: 13