Exemple #1
0
    //	Instantiates a new clock, using a clock prefab passed into this script and adds the clock to the list of spawned clocks.
    public void SpawnClock()
    {
        GameObject newClock = pooler.SpawnClockFromPool();

        // Only run the follwing code if clock was spawned
        if (newClock)
        {
            spawnedClocks.Add(newClock);

            // Allow for any clock to be removed if there is more than one clock in the scene
            if (spawnedClocks.Count == 2)
            {
                spawnedClocks[0].GetComponentInChildren <Button>().interactable = true;
            }

            // Stop clock spawns at 32 clocks
            else if (spawnedClocks.Count == 32)
            {
                spawnClockButton.interactable = false;
            }

            newClock.transform.SetAsLastSibling();
        }
    }