[SOLVED] Static Bool instead of MusicPlayer instance?

I tried this during the challenge and it worked. Is there a downside to this code compared to the instance/null way you showed?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MusicPlayer : MonoBehaviour {

    static bool musicPlayer = false;

	// Use this for initialization
	void Start () {
        if (!musicPlayer) {
        } else {
            print("Destroyed duplicate MusicPlayer");
        musicPlayer = true;

	// Update is called once per frame
	void Update () {

Answer found in this thread.

Privacy & Terms