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
↧