Get sprite atlas name

I am currently loading a sprite from an atlas using this:

public Sprite[] getSprites;
getSprites= Resources.LoadAll<Sprite>("tiles2");

and then assign a new one programmatically like this:

this.GetComponent<SpriteRenderer>().sprite = getSprites[6];

So it will set the 7th tile from the atlas to the sprite.

My question is …how can i get the name of the atlas the sprite is using, so i can then check its name and load a different one when i want ?

I know i can get the tile name like this:

string tileName = this.GetComponent<SpriteRenderer>().sprite.name;

But i cant figure out how to do the atlas.

56861-untitled.png

First, get the texture of the sprite, then get the name of the texture.

string tileTextureName = GetComponent<SpriteRenderer>().sprite.texture.name;