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.
The problem to this is I the inspector will not let me assign the script. It just wont let me drag into it with the correct script
– OptimisticCodethat means, check the spelling of script name
– MoorChecked it, doubled checked it, even changed it to a lowercase first letter. Nothing. I know right? In monodevelop it doesnt even turn blue... hint?
– OptimisticCode