title: Loading Texture in Unity always throws NullReferenceExpection
body: <p>I'm working in Unity 4.3.3f1 and I'm trying to load a Texture at runtime but I keep getting <code>NullReferenceExpection</code>.  I have my <code>.png</code> located in Asset/Resources as specified by <a href="https://stackoverflow.com/questions/15820890/loading-a-png-as-a-texture-at-runtime-in-unity3d">this question</a>.</p>
  
  <p>My actual code is </p>
  
  <pre><code>  Texture tex = Resources.Load("lava_pic", typeof(Texture)) as Texture;
    Rect pos = new Rect(transform.position.x - 50, 
          transform.position.y - 50, 100, 100);
  
    GUI.DrawTexture(pos, tex);
  </code></pre>
  
  <p>I've also tried with the <code>.png</code> extension</p>
  
  <p>The Error is </p>
  
  <pre><code>NullReferenceException: Object reference not set to an instance of an object
  UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image, ScaleMode  
    scaleMode, Boolean alphaBlend, Single imageAspect) (at     
  C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:208)
  UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image) (at 
   C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:204)
  LavaScript.FixedUpdate () (at Assets/Scripts/LavaScript.cs:35)'
  </code></pre>
  
  <p>If I put in a <code>Debug.Log(tex);</code> it also prints out <code>null</code> so that is where the problem is.</p>
  
  <p>I really don't know why this is occurring. It's in a Resources folder since <a href="http://docs.unity3d.com/Documentation/Manual/LoadingResourcesatRuntime.html" rel="nofollow noreferrer">that's where it needs to be</a> and I'm fairly certain it can be a <code>.png</code> file. What am I doing wrong?</p>