title: Object not set to reference in build
body: <p>I'm having some discrepancy between playing my unity project inside the editor, and playing the build it makes. </p>
  
  <p>Inside the editor, when I play my game I have code that spawns enemies when my player hits a target spot, which works. The enemies spawn and do what they need to do. However, when I build the project and run it, my player hits the same spot, but nothing appears. </p>
  
  <p>I ran the project in the development mode and it claims I have not set the reference which I thought I had. I mean, if it didn't work, why is it working in the editor?</p>
  
  <p>To try and combat this, I re-imported the assets I'm using. I remade the enemy spawn points. But I still get the same issue. </p>
  
  <p>Has anyone ever came across this before? 
  If so, how can I fix this issue when it works inside the editor, but not in the build?</p>
  
  <p>Here is my spawning function:</p>
  
  <pre><code>public GameObject SpawnEnemies()
  {
      Vector3 _position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
  
      // instantiate particel system
    //  Instantiate(_particle, _position, Quaternion.identity);
      audio.PlayOneShot(_appearSound);
  
      _clone = (GameObject)Instantiate(_enemy, _position, transform.rotation);
      _ai = _clone.GetComponent&lt;HV_BaseAI&gt;();
      _ai._waypoints = _wayPoints;
  
      return _clone;
  }
  </code></pre>
  
  <p>This is controlled by my section class which has the following function:</p>
  
  <pre><code>   public List&lt;GameObject&gt; SpawnGroundEnemies()
  {
      List&lt;GameObject&gt; groundObjectList = new List&lt;GameObject&gt;();
  
      for (int i = 0; i &lt; _spawnPoints.Count; i++)
      {
          groundObjectList.Add(_spawnPoints[i].SpawnEnemies());
      }
      return groundObjectList;
  }
  </code></pre>
  
  <p>Which, in turn is controlled by my section controller: </p>
  
  <pre><code>       GameObject g, f;
      g = GameObject.FindGameObjectWithTag("SectionController");
      f = GameObject.FindGameObjectWithTag("SectionController");
  
      HV_SectionController tempSectionControllerGroundEnemies, tempSectionControllerFlyingEnemies;
      tempSectionControllerGroundEnemies = g.GetComponent&lt;HV_SectionController&gt;();
      tempSectionControllerFlyingEnemies = f.GetComponent&lt;HV_SectionController&gt;();
  
      _groundEnemiesRemaining = tempSectionControllerGroundEnemies._numberOfGroundEnemies.Count;
      _flyingEnemiesRemaining = tempSectionControllerFlyingEnemies._numberOfFlyingEnemies.Count;
      _enemiesRemaining = _groundEnemiesRemaining + _flyingEnemiesRemaining;
  
      if (!_moving)
      {
          if (_enemiesRemaining == 0)
          {
              MoveToNextSection();
  
          }
  
      }
  
      if (_moving)
      {
          if (Vector3.SqrMagnitude(_camera.transform.position - _camNavMesh.destination) &lt; 5.0f)
          {
              _moving = false;
  
  
              // spawn the next set of enemies
              // need this for each section of the game
              // without this, no enemies will spawn
              if (CurrentSection == 1)
              {
                  _numberOfGroundEnemies = _sections[0].SpawnGroundEnemies();
                  _enemiesRemaining = _numberOfGroundEnemies.Count;
              }
  
              if (CurrentSection == 2)
              {
                  _numberOfFlyingEnemies = _sections[1].SpawnFlyingEnemies();
                  _enemiesRemaining = _numberOfFlyingEnemies.Count;
              }
  
              if (CurrentSection == 3)
              {
                  _numberOfGroundEnemies = _sections[2].SpawnGroundEnemies();
                  _enemiesRemaining = _numberOfGroundEnemies.Count;
              }
          }
      }
  }
  
  private void MoveToNextSection()
  {
      if (_currentSection == _sections.Count)
      {
          _currentSection = 0;
      }
      _camNavMesh.SetDestination(_sections[_currentSection]._cameraTransform.position);
      _lookAtPoint.SetTimer(_sections[_currentSection]._cameraLookAtTarget.position);
      _moving = true;
  
      _currentSection += 1;
  }
  </code></pre>
  
  <p>Can anyone see anything i'm doing wrong?</p>
  
  <p>Update</p>
  
  <p>Since this post, I've tried reimporting all of my assets again. I've even created a fresh project and done a fresh build that way, but I still have the same issue. Also, to help, I've take two screen grabs to show what I mean.</p>
  
  <p>First off, the game running in the unity editor:
  <img src="https://i.stack.imgur.com/40kel.png" alt="enter image description here"></p>
  
  <p>As you can see, there is 4 skeletons on the bridge. These guys appear when I hit play in the unity editor. </p>
  
  <p>Now, when I build the project, this is same sections:
  <img src="https://i.stack.imgur.com/quBvv.png" alt="enter image description here"></p>
  
  <p>As you can see, no enemies, but when its a development build, it says I've no reference set. In the output log unity genereates, it gives me this message:</p>
  
  <blockquote>
    <p>NullReferenceException: Object reference not set to an instance of an
    object   at HV_SpawnGroundEnemy.SpawnEnemies () [0x00052] in
    C:\Users\sean.obrien\Desktop\Medieval Darkride
    Level\Assets_scripts\Enemy Scripts\HV_SpawnGroundEnemy.cs:37 </p>
    
    <p>at HV_Section.SpawnGroundEnemies () [0x0000d] in
    C:\Users\sean.obrien\Desktop\Medieval Darkride
    Level\Assets_scripts\Helper Scripts\HV_Section.cs:26 </p>
    
    <p>at HV_SectionController.Update () [0x000c2] in
    C:\Users\sean.obrien\Desktop\Medieval Darkride
    Level\Assets_scripts\Helper Scripts\HV_SectionController.cs:72</p>
  </blockquote>
  
  <p>Again, this only appears in the built version of the game. When I run this inside Unity, everything works fine. I honestly have no idea why this issue arises when it works fine in the editor but not in the build.</p>