public AudioClip routineAudio;
public AudioClip gameAudio;
public AudioClip RewardAudio;
public string gameLevel="GameIn";
public string rewardLevel="Reward";
void Start(){
DontDestroyOnLoad(gameObject);
}
// Use this for initialization
void OnEnable () {
if(_PlayerPrefs.playerPrefs!=null)
{
float audioVolumn=PlayerPrefs.GetFloat(_PlayerPrefs.playerPrefs.MusicVolume,_PlayerPrefs.playerPrefs.oneF);
//Debug.Log("dfffffffggg "+audioVolumn);
if(audioVolumn==_PlayerPrefs.playerPrefs.zeroF){
audio.volume=audioVolumn;
//return;
}
else
audio.volume=audioVolumn;
}
string level=Application.loadedLevelName;
//Debug.Log("Audio ddfff "+level);
if(level==gameLevel)
{
audio.clip=gameAudio;
if(!audio.loop)audio.loop=true;
audio.Play();
//Debug.Log("Audio ddfff "+audio.clip.name);
}
else if( level==rewardLevel){
audio.clip=RewardAudio;
audio.loop=false;
audio.Play();
//Debug.Log("Audio ddfff "+audio.clip.name);
}
else
{
if(audio.clip!=routineAudio){
audio.clip=routineAudio;
audio.Play();
}
if(!audio.loop)audio.loop=true;
//Debug.Log("Audio ddfff "+audio.clip.name);
}
}