Local Variable Lost in Ifs

I have this method inside my Bodypart class:

public GameObject PartShape(string pname)
	{
		GameObject pshape;
		if (pname == "Bulb")
			pshape = Resources.Load ("p_bulb") as GameObject;
		else if (pname == "Wedge")
			pshape = Resources.Load ("p_wedge") as GameObject;
		else if (pname == "Segment")
			pshape = Resources.Load ("p_segment") as GameObject;
		else if (pname == "Limb")
			pshape = Resources.Load ("p_limb") as GameObject;
		else
			pshape = GameObject.CreatePrimitive (PrimitiveType.Plane);

		return pshape;
	}

It should define the bodypart prefab to use based on the name passed to Bodypart at instantiation. In a seperate Testing script I simply instantiate Bodypart and do some Debug.Logging. I’ve found that all the variables of Bodypart get set to what I pass into it, including partName. However by debugging partShape I get Null.

Question: Given the above function, used in the form “partShape = PartShape(partName);” inside Bodypart, why does it return Null?

Thanks in advance.

smoggach wrote

“Is it null in every case? Resources.Load(“p_limb”) will look in the Assets/Resources folder for anything called “p_limb”. You’ll get null if it can’t find any of these so the first thing to do is pinpoint which resource it’s failing to find. If it’s not finding any then the first thing to do is get it successfully finding SOMETHING.”

Sorted!