[SOLVED] Script not updating in Unity after saved in MonoDevelop?

Hello, I am having an odd problem where the code for the MusicPlayer.cs script is not updating when I’m adding my static changes. My code is identical to the code provided in the lesson, and I have gone over it line by line just to be sure multiple times.

I opened the Musicplayer.cs script by double clicking it in the Project pane. When I save, there is an X in the code tab and no asterisk behind the name. However, when I view my MusicPlayer.cs code in the Inspector, the code is the same as it was before the changes. No console command occurs to confirm that another MusicPlayer instance is destroyed, and they continue to accumulate when the Start Scene is loaded as before.

I have tried to:

  1. Delete the Music Player object in the Start scene and re-create it.
  2. Exit monodevelop and Unity and restart.
  3. Re-load the code from inside unity (it brings up the final version with static in Monodevelop).

I’m not sure what could be causing this. Any help would be very appreciated.

using UnityEngine;
using System.Collections;

public class MusicPlayer : MonoBehaviour {
	static MusicPlayer instance = null;

	// Use this for initialization
	void Start () {
		if (instance != null) {
			Destroy (gameObject);
			print ("Duplicate Music Player self-destructing!");
		} else {
			instance = this;
	// Update is called once per frame
	void Update () {

Weirdest thing, I restarted my computer and it was fixed upon reloading Unity.

I’ll leave this here in case any others need to be reminded of the golden rule:

“Have you tried turning off and on again?”


Privacy & Terms