void OnDestroy() { if (instance == this) { instance = null; } }
// Use this for initialization void Awake() { if (instance != null) { Destroy(gameObject); return; } instance = this; // numCarsSlider.onValueChanged.AddListener(NumCarsSliderValueChanged); // highwaySizeSlider.onValueChanged.AddListener(HighwaySizeSliderValueChanged); }