How to ignore these missing elements?
or
How to remove my destroyed target from the list? Source
public class SkinMananger : MonoBehaviour {
public GameObject[] characters;
public int selectedCharacter = 0;
public GameObject carrot;
public void NextOption()
{
characters[selectedCharacter].SetActive(false);
selectedCharacter = (selectedCharacter + 1) % characters.Length;
characters[selectedCharacter].SetActive(true);
}
public void BackOption()
{
characters[selectedCharacter].SetActive(false);
selectedCharacter--;
if(selectedCharacter < 0)
{
selectedCharacter += characters.Length;
}
characters[selectedCharacter].SetActive(true);
}
public void PlayGame()
{
PlayerPrefs.GetInt("selectedCharacter", selectedCharacter);
}
}
and I use Destroy(gameObject); for my characters when certain actions take effect. So I need a skin manager to work also when they are destroyed. As at this moment, it stuck.