When destroying plateGameObject of the type GameObject, i get error in my console “Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate (theObject, true);”, and the GameObject is not destroyed.
private void Awake()
{
plateVisualGameObjectList = new List<GameObject>();
}
private void Start()
{
platesCounter.OnPlateSpawned += PlatesCounter_OnPlateSpawned;
platesCounter.OnPlateRemoved += PlatesCounter_OnPlateRemoved;
}
private void PlatesCounter_OnPlateRemoved(object sender, System.EventArgs e)
{
GameObject plateGameObject = plateVisualGameObjectList[plateVisualGameObjectList.Count - 1];
plateVisualGameObjectList.Remove(plateGameObject);
Destroy(plateGameObject);
}
I tried turning plateGameObject into a field and i tried DestroyImmediate, that didnt work either. I also looked online, but only found people asking about destory(gameObject).
New contributor
Svak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.