- Home /
UI element wont destroy
I am making a game and in the begining i instantiate the main menu and i want it so when they press the play button it will destroy. heres the code:
void Start(){
menu = Instantiate (mainMenu,mainMenu.transform.position, Quaternion.identity)as GameObject;
menu.transform.SetParent (GameObject.Find ("Canvas").transform,false);
}
public void mainMenuPlayClick(){
scoreKeeper = GameObject.Find ("Score").GetComponent<ScoreKeeper> ();
paused = false;
Destroy (menu.gameObject);
print ("CLICKED");
scoreKeeper.nextWave ();
}
everything in the method works except the destroy.. please help!
Comment
Your answer
Follow this Question
Related Questions
How can I reference a Toggle? 3 Answers
Activate desactivate canvas with c# 1 Answer
How do you reference a Text on a Canvas - Unity 4.6 GUI 1 Answer
How Can I save my values with Toggles in UI canvas 4.6 through scenes? 3 Answers
Canvas Scaler does the exact opposite of what I think it would 0 Answers