List<EntryDate > PlayerEntryDateList =new List<EntryDate > ();
int currIndex=0;
GameObject currPlayerGo;
EntryDate currPlayerDate;
void UpdateUI()
{
int Count= PlayerEntryDateList.Count;
if (Count-1 == currIndex || Count - 1 == 0 )
{
rightButton.gameObject.SetActive(false);
}
else
{
rightButton.gameObject.SetActive(true);
}
if(currIndex==0 || Count - 1 == 0 )
{
leftButton.gameObject.SetActive(false);
}
else
{
leftButton.gameObject.SetActive(true);
}
}
GameObject CreatPlayer()
{
currPlayerDate = PlayerEntryDateList[currIndex];
var playerGo =Instantiate(currPlayerDate.prefab);
UpdateUI();
return playerGo;
}
void leftButton_Click()
{
currIndex--;
DestroyImmediate(currPlayerGo);
currPlayerGo = CreatPlayer();
}
void rightButton_Click()
{
currIndex++;
DestroyImmediate(currPlayerGo);
currPlayerGo = CreatPlayer();
}