How to check if FBX has a color when importing it?

Hi there guys!

I’m using an AssetPostprocessor to generate random colors for objects upon importing the FBX file (within OnAssignMaterialModel function). Everything works perfectly, but now I need to check if the imported FBX has colors on it. Why? Because some 3D editing tools export colors along with the FBX and others don’t (I believe Revit doesn’t). So the point is to maintain the original colors on the FBX files that have colors and generate the random ones on the FBX files that doin’t have colors on them.

Is it possible? According to the docs,

The sourceMaterial is generated directly from the model before importing and will be destroyed immediately after OnAssignMaterial.

So how am I supposed to know if the FBX comes with a color if the material I get in the OnAssignMaterialModel gets created before the function? If it already comes with a material then it will have either a default color or the original color, but how to make that distinction?

I don’t know if any of the properties of the ModelImporter (materialName or materialSearch) can solve the problem. Any ideas?

Thanks in advace.

[Edit] After looking at some answers (like this one), I’ve come to OnPostprocessGameObjectWithUserProperties. The downside is that it seems like it only searches for the custom user properties, not the FBX properties. Still stuck here. Is it possible to get the color of the Material or Nodeattribute properties of the FBX?

Unity only has the concept of colours in terms of materials. If you are reading in colour properties from custom user properties then it would need to generate materials based on that value and apply the material. The simplest process would be to ensure that the source package/export applies the colour to the object in the form of a material that Unity can read/generate at import