Hi, I need a quick help… I know it sounds silly, but I’m stock with this error for hours now, wondering what’s wrong with my code making this: Assets/Scripts/MusicManager.cs(29,2): error CS1525: Unexpected symbol ‘{’. I can’t just figured it out what’s wrong? I’m don’t think I’m lacking of open and close curly brackets { } ? Where is it?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[RequireComponent(typeof(AudioSource))]
public class MusicManager : MonoBehaviour {
private AudioSource audioSource;
[Tooltip("First to play and the main theme on scene")]
public AudioClip mainTheme;
[Tooltip("Normal music that have ending")]
public List<AudioClip> oneShotMusicList;
[Tooltip("A short or long looping music that can repeat seamlessly; Note: will play 1-2 times")]
public List<AudioClip> loopingMusicList;
void Start () {
audioSource = GetComponent<AudioSource> ();
StartCoroutine (MusicChange ());
}
IEnumerator MusicChange ()
{
yield return new WaitForSeconds(2);
int musicDirector = 0;
whlie (true)
{ //<-- Assets/Scripts/MusicManager.cs(29,2): error CS1525: Unexpected symbol '{'
int mainThemeExist = 0;
oneShotMusicList.RemoveAll (AudioClip => AudioClip == null);
loopingMusicList.RemoveAll (AudioClip => AudioClip == null);
if (mainTheme != null)
{
mainThemeExist = 1;
}
int playList = mainThemeExist + oneShotMusicList.Count + loopingMusicList.Count;
if (playList > 0)
{
int randomizer = Random.Range (0, playList + 1);
if (mainTheme != null && (randomizer == 0 || musicDirector == 0))
{
audioSource.clip = mainTheme;
musicDirector = 1;
}
else
{
for (int i = 1; i < playList; i++)
{
if (randomizer == i)
{
if (i <= oneShotMusicList.Count)
{
audioSource.clip = oneShotMusicList [i - 1];
musicDirector = 1;
}
else
{
audioSource.clip = loopingMusicList [i - oneShotMusicList.Count - 1];
musicDirector = 2;
}
}
}
}
if (musicDirector == 2)
randomizer = Random.Range(0, 2);
else
randomizer = 0;
for (int i = 0; i <= randomizer; i++)
{
audioSource.Play ();
yield return new WaitForSeconds(audioSource.clip.length);
}
}
yield return null;
}
}
}
I’m so sorry, I think I’m back to noob or forgot something. Thank you for your help!