Skip to content

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

Open
Grimeh wants to merge 1 commit intoSixWays:masterfrom
Grimeh:fix/parse-multiline-objects
Open

Fix parsing of entries with multi-line object references#11
Grimeh wants to merge 1 commit intoSixWays:masterfrom
Grimeh:fix/parse-multiline-objects

Conversation

@Grimeh
Copy link

@Grimeh Grimeh commented Jun 12, 2024

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant