Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    591
    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:
    591
    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:
    591
    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:
    591
    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:
    591
    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:
    591
    amirebrahimi_unity likes this.