how to detect destroyed object

so in my game if I drop an Item by dragging it it destroys the image of an Item in my inventory, and if the image is destroyed I want the target to be equal to the destroyed object. my problem is how can I detect a destroyed object.

So not super clear how everything works, but by how you’re describing it you can use null to check.

if(GetComponent<Image>() == null)
{
//Deleted?
}

if its not a component but rather a object. Then set the object as a variable in start. Then do the same when you want to check if its destroyed check if that variable is null or not and then keep on going with the code.

GameObject object;

if(object == null)
{
//its null
//destroyed?
}

thank you I also want to make the object equal to the destroyed object.

Destroyed objects don’t exist anymore, so it’d always be null. If you want it to be the name of the object or something, then you could always put a script on the object that would be destroyed and do what you need in OnDisable().