In a script I run I need to create an object. However once the script has run I would like to destroy the object, but I can’t figure out how to do it.
This sample highlights the problem
using UnityEngine;
using UnityEditor;
public class WillNotDestroy : EditorWindow
{
[MenuItem("Custom Tasks/Create And Destroy")]
static void CreateAndDestroy()
{
GameObject go = new GameObject();
go.name = "Help destroy me";
Destroy(go);
}
}