Search Unity

What is ActionMenuItem attribute for?

Discussion in 'EditorXR' started by De-Panther, Mar 15, 2017.

  1. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    I tried to change the tooltip text in one of our actions, the first thing I found was the ActionMenuItem attribute.
    Setting it did nothing but to include it in a Tooltips editor window.

    In the end I used the ITooltip interface and it worked.

    So if the ITooltip interface is the way to change tooltip text, what is ActionMenuItem attribute for?

    I'm confused
     
  2. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    ActionMenuItem is for adding actions that show up in radial menu once an object is selected. Tools can expose their own actions that show up once the tool is activated. TransformTool does this. For now, ActionMenuItem returns the name of the action as the tooltip, hence why it implements ITooltip.

    You can also implement tooltips elsewhere using ITooltip, ISetTooltipVisibility, and ITooltipPlacement if you need custom placement.
     
  3. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Lets say I have a class named SpinnerAction
    Above that I used the attribute
    [ActionMenuItem("Spin")]

    In the radial menu tooltip I'll see "SpinnerAction" instead of "Spin"

    But if I'll use the ITooltip with tooltipText="Hey" I'll see on the radial menu tooltip "Hey".

    So currently the ActionMenuItem do nothing, but in the future this will be the place to set the tooltip text?
     
  4. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    The radial menu tooltip should shown "Spin". If it doesn't, then that's a bug. However, the ActionMenuItem only works on a standalone action. If this is a tool action, then you would need to implement ITooltip and return the text you want. You'll see that the nested TransformAction does this because the tooltip text changes.
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    We have a tool class, that has inside it the radial menu action. So maybe this is why the ActionMenuItem attribute didn't work
     
  6. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Yes, for that your nested action class will need it's own ITooltip.
     
    De-Panther likes this.
  7. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Still feels confusing and inconsistent.
    But I have no idea how can you make it more clear to the developers
     
  8. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    That's good to know. Are you thinking you'd like to be able to use the attribute on your action? There still would be the need for implementing ITooltip if you need to be able to change your text dynamically.
     
  9. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Sounds good to me :)
     
  10. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Would you be willing to create an issue on GH for that? This way you'll get updates about when it gets implemented.
     
  11. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    amirebrahimi_unity likes this.