Checking if SpriteAtlas corresponds a preset

Hi!
I have a SpriteAtlas “atlas”, from which I’ve created a Preset “preset” from the Editor
However, If I use the DataEquals method of the preset, I always get “false”, even though the data is correct.

    var isDataEqual = preset.DataEquals(atlas) // Always return false!

For a SpineTexture, the following method worked:

    var texturePath = AssetDatabase.GetAssetPath(texture);
    var importer = AssetImporter.GetAtPath(texturePath) as TextureImporter;
    var isDataEqual = preset.DataEquals(importer) // This works as expected

So I tried to do something similar with a SpriteAtlas:

    var atlasPath = AssetDatabase.GetAssetPath(atlas);
    var importer = AssetImporter.GetAtPath(atlasPath) as SpriteAtlasImporter;
    var isDataEqual = preset.dataEquals(importer)

But that didn’t work as well
The Unity manual shows that I need to use the NativeFormatImporter Unity - Manual: Built-in Importers - but I cannot import it, it cannot be found in any namespace.
Is this a Unity bug? Is there a way to compare preset data for the SpriteAtlas after all?

1 Like

HI!

Which version of the SpriteAtlas are you using?
I can see that we have two versions:

  • The first one is a simple sprite atlas asset in a project, for which in that case the Importer is the NativeFormatImporter and should just be ignored, which means your first example should just work, and I’d be very curious if you could share you atlas asset and the preset you’re trying to use?
  • The new version is using an actual importer, in which case your last example should work, but I’m not sure how the settings are being shared between the importer itself and the asset, I’d have to dig a bit more into it to make sure.