So I have a script A trying to call script B's function. I get a NullReference because I am not able to get the script correctly, but I've followed the exact stuff I've seen on the forums. Why am I having such a problem with this?
**Script A:**
var diamManager : DiamondManger;
var diam : int;
diamManager = gameObject.GetComponent("DiamondManger");
function OnGUI() {
diam = diamManager.Diamonds();
}
**Script B:**
public function Diamonds(){
Debug.Log("diamonds = " + diamonds);
return diamonds;
}
the diam line in the OnGui function is where I am getting my NullReference error.
↧