public class AudioManager : MonoBehaviour
{
private static AudioManager audioManager = null;
private void Start ()
{
if (audioManager != null)
{
Destroy(gameObject);
print(audioManager + "'s self destroy requested.");
}
else
{
audioManager = this;
GameObject.DontDestroyOnLoad(audioManager);
}
}
}
I know this code's function which is if there is an audioManager than destroy the new and than the audioManager only exist once so the audio of the audiomanager doesnt make a new audiomanager and so there wont be loop so i am going to hear the attached audio file only once. But can someone explain me that what is "this" and what is it used for and do the same with "static" keyword? Thanks for the help, Kristóf