void Start() { MusicTimer.OnWhole += OnWhole; MusicTimer.OnHalf += OnHalf; MusicTimer.OnQuarter += OnQuarter; MusicTimer.OnEighth += OnEighth; MusicTimer.OnSixteenth += OnSixteenth; MusicTimer timer = GameObject.FindObjectOfType <MusicTimer>(); float barLength = timer.barLength; whole = Instantiate <Blinker>(dotPrefab, new Vector3(-8, 0, 0), Quaternion.identity); whole.fadeTime = barLength; for (int i = 0; i < 16; i++) { if (i % 8 == 0) { halves[i / 8] = Instantiate <Blinker>(dotPrefab, new Vector3(-8 + i, -1, 0), Quaternion.identity); halves[i / 8].fadeTime = barLength / 2; } if (i % 4 == 0) { quarters[i / 4] = Instantiate <Blinker>(dotPrefab, new Vector3(-8 + i, -2, 0), Quaternion.identity); quarters[i / 4].fadeTime = barLength / 4; } if (i % 2 == 0) { eighths[i / 2] = Instantiate <Blinker>(dotPrefab, new Vector3(-8 + i, -3, 0), Quaternion.identity); eighths[i / 2].fadeTime = barLength / 8; } sixteenths[i] = Instantiate <Blinker>(dotPrefab, new Vector3(-8 + i, -4, 0), Quaternion.identity); sixteenths[i].fadeTime = barLength / 16; } }
public void initTimer() { musicTimer = Instantiate(preFabTimer); if (!musicTimer) { Debug.Log("No music timer created."); } DontDestroyOnLoad(musicTimer); }