- Home /
Destroy game object forever?
How to destroy object forever? when i go to another scene and back to first, i want to that object stay destroyed!
Answer by Dacke · Jan 18, 2014 at 06:35 PM
i found solution. If someone needs it's simple. I make string array, and it remember name of every destroyed object. Then delete that object on stat.
public static List namesOfDestroyedObjects = new List();
void Start () {
if(namesOfDestroyedObjects.Count>0){
for (int i = 0; i < namesOfDestroyedObjects.Count; i++) {
Destroy(GameObject.Find(namesOfDestroyedObjects[i]));
}
}
}
void OnMouseDown (){
namesOfDestroyedObjects.Add(this.gameObject.name);
Destroy(this.gameObject);
}
this nameOfDestroyedObjects.Add() works like playerprefs? or it resets to default after I reset the scene?
Answer by mohammadawwad · Aug 12, 2020 at 01:38 AM
Im having a simmilar issue and still dont onow how to fix it but mine is with coins
Your answer
Follow this Question
Related Questions
Destroy function not documented? 2 Answers
Unity createNew Game Object after calling a Destroy() 1 Answer
destroying cloned prefab not working as intended 0 Answers
How to destroy an object gradually? 1 Answer
count score start 0 2 Answers