Должно работать, не проверял.
using UnityEngine;
using System.Collections.Generic;
public class Breakfast : MonoBehaviour
{
public GameObject[] objects;
private List<int> _remainingObjects;
public void Start()
{
InitializeObjects();
}
public void Push()
{
if (_remainingObjects.Count == 0)
{
InitializeObjects();
}
int randomIndex = Random.Range(0, _remainingObjects.Count);
int objectToShowIndex = _remainingObjects[randomIndex];
objects[objectToShowIndex].SetActive(true);
_remainingObjects.RemoveAt(randomIndex);
}
private void InitializeObjects()
{
_remainingObjects = new List<int>();
for (int i = 0; i < objects.Length; i++)
{
_remainingObjects.Add(i);
objects[i].SetActive(false);
}
}
}