Link to a Static Var is gone after re-compliling during editor game play

Hello! I have this code:

// master.js
private static var data    : master;

public static function Control() : master {
    return data;
}

(I believe it was @Eric5h5 who deserves credit for that code, per another answer, likely from years ago, I found while googling!)

It allows me to call variables on that script as such: master.Control().variableName; or master.Control().RunFunctionName();

However, when I go into mono develop and fix a bug, after I come back into Unity, none of the lines starting with master.Control() work – instead I get a Null Reference Exception: NullReferenceException: Object reference not set to an instance of an object

I realize this is likely just an editor issue, but it makes it ever so slightly more annoying to debug, as I have to stop then start the game again to test. Also, on the off chance it’s not just an editor issue, I’d like to fix it now, rather than later.

Any ideas why this may be happening, or what I can do to re-link whatever is broken? My understanding was that every time i call master.Control() it re-links the data I’m looking for. But I am usually wrong about things :smile:

sounds like a dumb error, but try…

public static function Control() : master {
    return master.data;
}

Thanks for the tip – unfortunately the behavior is exactly the same. Things work, but only until I change a script and come back into unity.