Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        audio = GetComponent <AudioSource>();

        if (PlayerPrefs.GetInt("MusicOn") == 1)
        {
            audio.Play();
        }
        else
        {
            if (audio.isPlaying)
            {
                audio.Stop();
            }
        }

        // Singelton
        if (mController != null)
        {
            Destroy(gameObject);
        }
        else
        {
            mController = this;
            DontDestroyOnLoad(gameObject);
        }
    }
Пример #2
0
    private void Awake()
    {
        if (gameStatus == null)
        {
            gameStatus = this;
        }
        else if (gameStatus != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }