title: Unity3D c# check if event is null
body: <p>For example, DelegateHandler is where I sent event</p>
  
  <pre><code>public class DelegateHandler : MonoBehaviour
  {
  
       public delegate void OnButtonClickDelegate ();
       public static OnButtonClickDelegate buttonClickDelegate;
  
       public void OnButtonClick()
       {
       if(buttonClickDelegate!=null)
         buttonClickDelegate ();
       }
  
  }
  </code></pre>
  
  <p>Some thread mentioned I need to assign a variable to the event before checking if it is null like :</p>
  
  <pre><code>    OnButtonClickDelegate tempEvent = buttonClickDelegate;
      if(tempEvent!=null)
         tempEvent();
  </code></pre>
  
  <p>This is because, in multi-thread program, we need to check if some is unsubscribed from the event between checking it is null and invoking event.
  But Unity3D is single-threaded, do we also need to do this? Can I just write as  </p>
  
  <pre><code>     if(buttonClickDelegate!=null)
         buttonClickDelegate ();
  </code></pre>