undoing DontDestroyOnLoad without immediately destroying the object

After calling DontDestroyOnLoad on a game object that we want to pass between levels. Eventually we want to finally destroy it... say to reset the game to the initial state.

Is there a way of undoing DontDestroyOnLoad without immediately destroying the object..

the command: Destroy(this.gameObject); will cause issues if other game objects that are in the same scene still depend on it. I just want it to get destroyed with all of the other game objects on the next level load.

To undo a DontDestroyOnLoad, simply make a new GameObject and set it as parent of the object that was previously DontDestroyOnLoad.

GameObject bla= ...something;

GameObject newGO = new GameObject();
bla.transform.parent = newGO.transform; // NO longer DontDestroyOnLoad();

Like I said in another post: DontDestroyOnLoad() simply moves an object to the special Scene “DontDestroyOnLoad”, so all you need to do is move it back to the active scene:

SceneManager.MoveGameObjectToScene(TargetGo, SceneManager.GetActiveScene());

No way to do it automagically no

best way i can think of doing it is this:

var destroyOnLoad = false;

function OnLevelWasLoaded(level : int)
    if (destroyOnLoad) Destroy(gameObject);

that way you get your object destroyed before the first update in the new level

If you're destroying it and it's then being recreated for the level you've just loaded to (I'm assuming this from your comment about destroy and destroyimmediate) why don't you make a reset method for the object that puts it back in its initial state.

That way you could just replace the destruction with a reset and carry on.