Scene object context menu

Hi, does anybody know if it is possible (and if yes then how) to add menu item to scene object context menu in hierarchy?
7535930--930686--upload_2021-9-30_17-26-3.png
I can’t find the information nor figure it out.

I found the answer:

void Awake()
{      
    UnityEditor.SceneManagement.SceneHierarchyHooks.addItemsToSceneHeaderContextMenu += AddMenuItem;
}

private void AddMenuItem(GenericMenu menu, Scene scene)
{
    menu.AddItem(EditorGUIUtility.TrTextContent("Test"), false, Test);
}

private void Test()
{
    Debug.Log(this.GetHashCode());
}
2 Likes