Relevant part of the script:
public object[] pictures;
public int counter = 1;
void Update (){
GetComponent().sprite = (Sprite)pictures[counter];
}
This code works as it should, it changes the sprite of my GameObject to the desired object in the pictures[] array, the script works fine. But my only problem is that every frame the compiler gives me the **"Cannot cast from source type to destination type"** error, even though it works as it should. I would ignore this, but I'm pretty sure that when I try to build the game it wouldn't let me until I fix this error.
What is wrong, and how do I fix it?
↧