title: How developers keep reference to huge number of different entity prefabs?
body: <p>I am developing a game where I am generating infinite world like Minecraft's. The problem is that my game will have hundreds of types different animals and enemies, but I am not sure what is the usual approach of referencing those prefabs.</p>
  
  <p>My solution at the moment is to have an animal factory class that can spawn animals. Looks something like this:</p>
  
  <pre><code>public static class AnimalFactory
  {
      public static GameObject sheep = Resources.Load&lt;GameObject&gt;("Prefabs/Animal/Sheep");
      public static GameObject cow = Resources.Load&lt;GameObject&gt;("Prefabs/Animal/Cow");
  
      public static void SpawnSheep(float x, float y)
      {
          GameObject drop = Object.Instantiate(sheep, new Vector3(x, y, 0f), Quaternion.identity);
      }
  
      public static void SpawnCow(float x, float y)
      {
          GameObject drop = Object.Instantiate(cow, new Vector3(x, y, 0f), Quaternion.identity);
      }
  }
  </code></pre>
  
  <p>But should I be caching reference to all prefabs or simply use <code>Resources.Load&lt;GameObject&gt;</code> once I need the reference?</p>
  
  <p>I should also mention that animals get spawned fairly often.</p>
  
  <p>So, what is the usual approach here? How do developers usually spawn animals if there are hundreds of different types in the game?</p>