title: UnassignedReferenceException in Unity
body: <p>I am getting the error </p>
  
  <blockquote>
    <p>UnassignedReferenceException:</p>
  </blockquote>
  
  <p>even after assigning it in the Editor?</p>
  
  <p>I think the following screenshot provides everything needed.</p>
  
  <p>The screenshot below shows that the <code>muzzleFlash</code> variable has something assigned to it but it still causing error.</p>
  
  <p><a href="https://i.stack.imgur.com/43gVI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/43gVI.jpg" alt="enter image description here"></a></p>
  
  <pre><code>using UnityEngine;
  public class GUN : MonoBehaviour 
  {
  
      public float dmg =10;
      public float range=100;
      public Camera fpscam;
      public ParticleSystem muzzleFlash;
  
      void Update () 
      {
  
          if (Input.GetMouseButtonDown(0)) 
          {
              shoot ();
          }
      }   
  
      void shoot ()
      {   
          muzzleFlash.Play ();
          RaycastHit hit;
  
          if (Physics.Raycast (fpscam.transform.position, fpscam.transform.forward, out hit, range))
          {
                  Debug.Log (hit.transform.name);
                  Target target = hit.transform.GetComponent&lt;Target&gt; ();
  
                  if (target != null) 
                  {
                      target.takedmg (dmg);
                  }
          }
  }
  </code></pre>