Converting PolyMesh Colors from Unity 2021 to Unity 2022

Hi everyone,

After upgrading my project from Unity 2021 to Unity 2022, I’ve encountered an issue where the colors in my PolyMesh appear incorrect. The old color values were serialized in a different format, and I need to convert them to the new format required by Unity 2022.

Here’s an example of the old serialization format:

- target: {fileID: 5374454402836207861, guid: db63478ce07ba4364ba24cae8588c5fe, type: 3}
  propertyPath: m_PolyMesh.colors.Array.data[9].rgba
  value: 4278190335
  objectReference: {fileID: 0}

And the new format looks like this:

- target: {fileID: 5374454402836207861, guid: db63478ce07ba4364ba24cae8588c5fe, type: 3}
  propertyPath: m_PolyMesh.colors.Array.data[0].r
  value: 1
  objectReference: {fileID: 0}
- target: {fileID: 5374454402836207861, guid: db63478ce07ba4364ba24cae8588c5fe, type: 3}
  propertyPath: m_PolyMesh.colors.Array.data[0].g
  value: 0
  objectReference: {fileID: 0}
- target: {fileID: 5374454402836207861, guid: db63478ce07ba4364ba24cae8588c5fe, type: 3}
  propertyPath: m_PolyMesh.colors.Array.data[0].b
  value: 0
  objectReference: {fileID: 0}
- target: {fileID: 5374454402836207861, guid: db63478ce07ba4364ba24cae8588c5fe, type: 3}
  propertyPath: m_PolyMesh.colors.Array.data[0].a
  value: 1
  objectReference: {fileID: 0}

Is there a way to automatically convert these old color values to the new format during the prefab import process? Any scripts or tools to help with this would be greatly appreciated!

You can upgrade your prefab instances by getting the property modifications in the old format, convert them to the new format and set them to your prefab instance. The old format is a 32bit RGBA value and the new format is UnityEngine.Color (4 floats). You should be able to detect if the override if for the color by checking the property path

Thanks @MirceaI

I will try this approach for sure.

But what I did is another hack.

I did the following (as far as I remember):

  • duplicated the project and opened the other one with unity 2021.

  • copied the array of colors from 2021. It is a json format data kept in clipboard

  • wrote a script to convert the json to new format which is supported by unity 2022

  • applied that colors the the component.

If anyone else need more details, I can share the details.