Quantcast
Channel: Latest Questions by OptimisticCode
Viewing all articles
Browse latest Browse all 6

Problem calling another scripts function (JS)

$
0
0
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.

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>