Пример #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        if (!PlayerPrefs.HasKey("SFX Volume"))
        {
            PlayerPrefs.SetFloat("SFX Volume", 0.7f);
        }

        foreach (AudioFile file in soundFiles)
        {
            file.source        = gameObject.AddComponent <AudioSource>();
            file.source.clip   = file.audioClip;
            file.source.volume = PlayerPrefs.GetFloat("SFX Volume");
            file.source.loop   = file.isLooping;
        }
    }
 private void Awake()
 {
     if (_Instance == null)
     {
         _Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }