Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

onClick.AddListener IndexOutOfRangeException error and listener not seen in inspector

$
0
0
I am trying to make a simple system where a player can warp to any nearby warp pad. I am able to properly get all warp pads (layermask'ed) within the wanted distance, and properly instantiate and display the buttons in "warpScreen" (blank panel with horizontal guide). When I click the button, the error shoots back out at me on ONLY the buttons being instantiated from the for loop (looping through Colliders list of found warpPads). My "Exit" button works perfectly fine. void WarpPadCheck() { RaycastHit hit; if (Physics.Raycast(body.transform.position, -Vector3.up, out hit)) { if (hit.transform.gameObject.layer == 8) { warpScreen.SetActive(true); Collider[] hitColliders = Physics.OverlapSphere(hit.transform.position, 200f, warpPadMask); GameObject newB = Instantiate(button) as GameObject; newB.SetActive(true); newB.transform.SetParent(warpScreen.transform, false); newB.transform.GetChild(0).GetComponent().text = "Close"; newB.GetComponent

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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