How can using a static member (Camera) cause a NullReferenceException?


I was attempting to use OnGUI() to create a healthbar that hovers above my enemy units, and I noticed that whenever I click on the screen, a swathe of NullReferenceException errors shows up on my console. The line causing the error is Camera.current.WorldToScreenPoint(transform.position). From my understanding, Camera is a static member of UnityEngine. So the main question here is, how am I getting a null reference error when I’m referencing a static field?

	void OnGUI() {
		Vector3 pos =
		pos.y = Screen.height - (pos.y + 1);

		GUI.BeginGroup(new Rect(pos.x - 4, pos.y, size.x, size.y));
			GUI.Box(new Rect(0,0, size.x, size.y), bgTexture, healthStyle);
			float truePercent = rawPercent / 100f;
			GUI.BeginGroup(new Rect(0,0, (float)size.x * truePercent, size.y));
				GUI.Box(new Rect(0,0, size.x, size.y), healthbarTexture, healthStyle);

I answered a question very similar to this a while ago. Please go here and read my reply, as you are probably experiencing the same issue now: