- Home /
destroy prefabs
public class Manager : MonoBehaviour {
void Update(){ if (selectedlevel == 2 && ini == false && Play_Button.reached == true) { if(AgainButtonPress.again==true) { Debug.Log("again button is pressed"); // Destroy(clone, 2f); TapTile.wrongchoice=false; Destroy (clone.gameObject);
AgainButtonPress.again=false;
}
//Destroy(Instantiate(mul2, new Vector3 (0, 2, -10), Quaternion.identity));
clone = (GameObject)Instantiate (mul2, new Vector3 (0, 2, -10), Quaternion.identity);
//Instantiate (mul2, new Vector3 (0, 2, -10), Quaternion.identity);
//Destroy(mul2);
ini = true;
// buttonpressed = false;
} }
}
public class AgainButtonPress : MonoBehaviour { public GameObject camera; public static bool again=false;
void OnMouseEnter()
{
}
void OnMouseDown()
{
// transform.animation.Play ("ButtonPress"); camera.transform.position=new Vector3(0,4,-10); Manager.selectedlevel = 2; Manager.buttonpressed = true; Manager.ini=false; again = true;
//Destroy( GameObject.Find( "multiple2" ), 3 );
//Destroy(GameObject.FindWithTag("Untagged"));
}
i want to destroy the game object when the again button is pressed then instantiate the game object once again..At first the game object is instantiated perfectly but after the again button is pressed the game object is not destroyed..
Answer by Stormizin · Sep 04, 2014 at 12:37 PM
The line:
if(AgainButtonPress.again==true) {
Debug.Log("again button is pressed");
// Destroy(clone, 2f);
}
Destroy method is commented.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Is there an opposite of GameObject.FindGameObjectsWithTag() ? 2 Answers