Grabbing texture from resources, issue.

My issue is quite simple, but annoying. I am loading my resources wrong, but I don’t know what I am doing wrong (first time loading dynamically from a resource folder).

So this is what my code looks like:

			Item cItem = new Item(int.Parse(id),name,descr,
								Resources.Load("ItemSprites/"+tex) as Texture);

Obviously everything is very arbitrary with this little snippet, but tex is a string for the texture’s name and ItemSprites is the folder withing my Resources folder.
PIC:

I know for sure that tex is correct because I am printing it out right that line of code.

When I am trying to draw my texture I get this:

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/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:157)
UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:152)
UIManager.OnGUI () (at Assets/Scripts/UIManager.cs:307)

Here is the drawing code:

			int _i = 0;
		foreach(KeyValuePair<int, Item> item in InventoryManager.Items)
		{
			GUI.DrawTexture(new Rect(90*_i,0,60,60),item.Value.tex);	
			_i++;
		}

Obviously its not yelling at me for my Item being null since I am looping through my dictionary, which means my texture must be null. So that means I am loading the resource wrong! What am I doing wrong?

Thanks in advanced!

Stick a breakpoint in and determine what is actually null.

You might also want to try forward slashes as the path separator.

I am pretty darn sure its the texture that is null. Just did a check to see if the item is null, and it wasn’t.
Also, I feel dumb for using the wrong slashes XD But it didn’t fix the issue.

Wow. Found the problem.
In my XML file, the VERY FIRST item had its name wrong by accident, that caused the error and then the loop stopped, not letting the other, correct, ones to draw.