Search Unity

Bug Event.current does not capture Right Click -> Duplicate Event

Discussion in 'Editor & General Support' started by Jamoy1993, Oct 14, 2021.

  1. Jamoy1993

    Jamoy1993

    Joined:
    Jan 17, 2014
    Posts:
    14
    I have been looking at some code to do with this for a while now. Here is something akin to what I currently have:

    Code (CSharp):
    1.  
    2.  
    3. void OnValidate()
    4. {
    5.     Event e = Event.current;
    6.  
    7.     if (e != null)
    8.     {
    9.         if (e.commandName == "Duplicate" || e.commandName == "Paste")
    10.         {
    11.             ///Do Stuff
    12.         }
    13.     }
    14. }
    15.  

    It works perfectly when I use the keyboard to either duplicate or copy-paste an object and drag and drop from the project view and even when I go into the Edit -> Duplicate / Copy / Paste commands.

    The problem is, I noticed when I right-click on the object in the hierarchy and then click on duplicate or copy / paste that it does not trigger these events or even the OnValidate code?

    Wondering if this is definitely a bug?