void InstantiateButtons(GameObject[] moveButtons, GameObject[] infoButtons, GameObject[] goInsideButtons) { foreach (GameObject move in moveButtons) { MoveLocInteractive moveScript = move.GetComponent <MoveLocInteractive>(); if (PanelInstance.transform.Find(moveScript.myPanel) != null) { Transform panel = PanelInstance.transform.Find(moveScript.myPanel); GameObject newButton = Instantiate(move, panel.position, panel.rotation); //MoveLocInteractive script = newButton.GetComponent<MoveLocInteractive>(); //script.enabled = true; newButton.transform.SetParent(panel); newButton.transform.Translate(new Vector3(moveScript.xOffset, moveScript.yOffset)); } else { Debug.Log("A button was not properly assigned a panel"); } } foreach (GameObject info in infoButtons) { DisplayInfoInteractive infoScript = info.GetComponent <DisplayInfoInteractive>(); if (PanelInstance.transform.Find(infoScript.myPanel) != null) { Transform panel = PanelInstance.transform.Find(infoScript.myPanel); GameObject newButton = Instantiate(info, panel.position, panel.rotation); //ENABLE SCRIPT HERE/////////////////////////////////////////////////////////////////////////////// newButton.transform.SetParent(panel); newButton.transform.Translate(new Vector3(infoScript.xOffset, infoScript.yOffset)); //newButton.transform.LookAt(DPanels.transform); } else { Debug.Log("A button was not properly assigned a panel"); } } foreach (GameObject inside in goInsideButtons) { GoInsideInteractive goInsideScript = inside.GetComponent <GoInsideInteractive>(); if (PanelInstance.transform.Find(goInsideScript.myPanel) != null) { Transform panel = PanelInstance.transform.Find(goInsideScript.myPanel); GameObject newButton = Instantiate(inside, panel.position, panel.rotation); newButton.transform.SetParent(panel); newButton.transform.Translate(new Vector3(goInsideScript.xOffset, goInsideScript.yOffset)); } else { Debug.Log("A button was not properly assigned a panel"); } } }
public void loadArea(GameObject hitMoveButton) { MoveLocInteractive script = hitMoveButton.GetComponent <MoveLocInteractive>(); sphereScript.SphereSetup(script.moveButtons, script.infoButtons, script.goInsideButtons); Text infoText = PlayerHUD.GetChild(0).GetChild(0).GetComponent <Text>(); infoText.text = ""; Image picture = PlayerHUD.GetChild(1).GetChild(0).GetComponent <Image>(); picture.sprite = blankSprite; }