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

        DontDestroyOnLoad(gameObject);
    }
Пример #2
0
    // Use this for initialization

    private void Awake()
    {
        background = GetComponent <AudioSource>();
        string scene = SceneManager.GetActiveScene().name;

        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
            background.Play();
        }
    }