In my game, there are tons of places where I need to play audios after functions complete, for example
Class Player{
public clip;
void WalkToDestination()
{
//walk code here
AudioManager.Play(clip);
}
}
Class GameManger{
public clip;
void AfterCompleteLevel()
{
//play level completion animation
AudioManager.Play(clip);
}
}
Since there are so many functions requiring playing sound, and every time I have to add public AduioSource clip
into the class, and AudioManager.Play(clip);
into the body, there are too much repetitive work. is there any good design pattern for this?
Aucun commentaire:
Enregistrer un commentaire