using UnityEngine;
using System.Collections;
public class ClickButton : MonoBehaviour {
public string Previous = "";
public GameObject PopUp;
void OnMouseDown()
{
Destroy(GameObject.Find(Previous));
Instantiate(PopUp);
}
}
Everytime I run and click on the button the clone object stays and instantiates the new object however if the object is not a clone it works fine. However it being a clone is necessary
Hm, I believe that might be because cloned objects usually have a name like “PrefabName (Clone)”, perhaps. You usually would have to set the name of the cloned objects directly, like, newObject.name = Previous.
Could you see what the name of the instantiated objects are?