I want to instantiate new prefab in array and delete the old one when user click on the next button or on previous button.
I have the array of gameobject prefab something like this:
public GameObject[] prefabMoles = new GameObject[3];
GameObject[] moles = new GameObject[3];
void Start () {
for(int i = 0; i < prefabMoles.Length; i++)
{
moles[i] = (GameObject) GameObject.Instantiate(prefabMoles[i], new Vector3((i-1)*5, 0, 0), Quaternion.identity);
}
}
So now I want to add button on canvas which will be next character and previous will return back one number in array.
For example: I have Moles array and i instantiate moles[2]; On click on next button I want to destroy moles[2] and instantiate moles[3].
When we are on moles[3] and when we click previous we must destroy moles[3] and instantiate moles[2].
It would be great to have some effect of spawn new one but doesn't matter. And then when instantiate the new the button must popup for unlock or for select if the character is unlocked.
Thank you so much community for help if that is possible.