How to check the current sprite in the image source? Unity 4.6beta20

Hey, so I’m making an inventory and I need to check if the image source in the image component is “Blank_Icon” which is an actual sprite. So I added the Blank_Icon sprite to the Resources and the code goes like this:

public void AddItemToInventory(string itemName)
    {
        for (int i = 0; i < 2; i++) {
            if (invIcons*.GetComponent<Image>() == Resources.Load("Blank_Icon")) {*

print(“Found an empty space!”);
break;
}
}
}
This doesn’t work thought so how could I make it work? Thanks!

It appears you’re comparing an Image class to a sprite. The Image contains a sprite, so the following should do what you want:

if(invIcon*.GetComponent<Image>().sprite == Resources.Load("Blank_Icon")) {*