Simple code to make sure the main Sprite is set

Hello,
What if you have plenty of brick types and you want to make sure all the main sprites are located.
I attached this code to the Start() Method:

in Brick.cs

Sprite brickSprite = gameObject.GetComponent().sprite;
if (brickSprite == null)
{
Debug.LogError(“No Sprite detected on Brick object !”);
}

That should do the trick !
Thanks and all the best,
Ido

Privacy & Terms