What I am trying to do is to create a specific c# script (called: ConfirmOnDestroy.cs; for example) that prompt me a confirm message after a right-click on the gameObject from the hierarchy with this script attached->ContextMenu->Delete so it does not destroy immediately but only after I confirm that I actually want to delete it.
I don’t think you can ‘easily’ modify the default behaviour of the default ‘delete’ button in the context menu (you can hack it of course, but there’s no need to…) - You could use [EditorUtility.DisplayDialog][1] and put it in a static utility class and make a MenuItem out of it. Put this in an Editor folder:
public static class Tools
{
[MenuItem("Tools/Delete GO %&d")] // Alt-Ctrl-d
public static void ConfirmDeleteGO()
{
int len = Selection.gameObjects.Length;
if (len <= 0) return;
bool yes = EditorUtility.DisplayDialog("Confirm delete", "Are you sure you want to delete the selected GameObject(s)?", "Yes", "No");
if (yes)
for(int i = len-1; i > -1; i--)
Destroy(Selection.gameObjects*);*
Couldnt you just drag the gameobject into your project view? then even if it gets deleted in scene hierarchy you can just drag it back over from your project view. Also if you try to delete something in project view, you have to confirm it. If you make any changes to it in scene then just hit “apply” and all changes will be saved to prefab. Seems easier to me