How can I get info about what is my current sprite

Hey all,

I have a script where my sprite (Random Sprite) changes as I grow, I’m using enums/switch to change my sprites. I am wondering if it’s possible to be able to find which sprite got picked, since it is random.

I want to be able to do use an if statement kinda of thing. Like, if (sprite_001 got picked) do this.

I know I can probably get the name of the sprite but is that the way to do it?

Here’s my current script for randomly choosing a sprite.

switch ( nanoStage1States )
		{	
		case NanoStage1States.Level0:
			//NanoLevel1BoardSpriteRenderer.sprite = null;
			//NanoLevel2BoardSpriteRenderer.sprite = null;
			break;
		case NanoStage1States.Level1:

			if(!isCreatedlevel1){
				NanoLevel1BoardSpriteRenderer.sprite = Resources.Load<Sprite>("Nano_S1_Level1_Board/Level1_Board" + Random.Range(0,9));
				//Copper -= 2;
				Aluminiam -= 4;
				Silicone -= 1;

				maximumTargetRange = 8;



				mySphereCollider.radius += 0.18f;
			
				isCreatedlevel1 = true;
			}
		

	

			break;
		case NanoStage1States.Level2:

			if(!isCreatedlevel2){
				NanoLevel2BoardSpriteRenderer.sprite = Resources.Load<Sprite>("Nano_S1_Level2_Board/Level2_Board" + Random.Range(0,9));
				//Copper -= 5;

				maximumTargetRange = 12;
				mySphereCollider.radius += 0.18f;
				isCreatedlevel2 = true;
			}
			
			break;

if (NanoLevel1BoardSpriteRenderer.sprite != null)
{

			if (NanoLevel1BoardSpriteRenderer.sprite.name == "Level1_Board8")
		{
			Debug.LogError("WOOOOOOOOOOHOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
		}
}

So this totally worked…lol

I’m sure it’s far from being the best way though.