Been spending 3 hours trying to figure this out and my mind is about to explode.
ERROR: NullReferenceException: Object reference not set to an instance of an object
My prefab is a blank object with just GuiText added to it. I see this work in JavaScript but not C#
BTW are there any articles or good books on the exact structure of instantiated objects/prefabs? Due to the nature of Unity I spend hours and hours just figuring something out like this. I’d like a top down big picture book of how it all interacts so I have a better idea of how to resolve problems like this. I love Unity but I find the documentation a bit lacking. Although it is better than it was before. Could be the way I learn, visually.
public Transform damageNumScroller;
//prefab of empty object with just GUIText
.
.
. //later in a method
.
public void ScrollDamageUp(int numberToFloat, float x, float y, float z) {
GameObject popup = Instantiate(damageNumScroller, new Vector3(x, y, z), Quaternion.identity) as GameObject;
popup.guiText.text = "" + numberToFloat; // <---- ERROR IS HERE
popup.guiText.material.color = new Color(1f, 1f, 1f, 1f);
}