Problem with C# events and singletons.

Hey all,

First time using events and I ran into this strange problem.

so i set up my event in another class like this,

public delegate void GlassBroken();
public static event GlassBroken OnGlassBroken;

And then subscribe a method to that event in another class

Glass.OnGlasstBroken += CheckGlass;

However when i go to use the method “CheckGlass” I get a “Object of type text has been destroyed…”

scoreBoard.text = currentScore.ToString();//Returns error
MyClass.singleton.scoreBoard.text = currentScore.ToString(); //No error

The code runs fine in another method like Start.

This is my first time with events, am i missing something?

Seems like a script execution order problem to me. Where do you get scoreBoard from? Why aren’t you accessing it through the singleton like the second line?