Search Unity

Troubling Tool Tips

Discussion in 'Immediate Mode GUI (IMGUI)' started by BinaryCats, May 9, 2016.

  1. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Hi,

    I have a slight issue with the tool tip attribute, and frankly will be impressed if somebody knows a solution.

    --The tool tip attribute allows tool tips to be drawn when you mouse over fields in the inspector

    My problem is I have attribute A, which I want to alter what the tool tip says.

    In my draw code for attribute A I do something like this:

    Code (csharp):
    1.  
    2. object[] atrs = fieldInfo.GetCustomAttributes(typeof(TooltipAttribute), false);
    3.  
    4. if (atrs.Length > 0 )
    5.  
    6. oldTT = ((TooltipAttribute)atrs[0]).tooltip;
    7.  
    8. label.tooltip = oldTT + "\n" + "more ToolTipText";
    9.  
    This works fine.

    HOWEVER The order the draw for the tool tip or attribute A gets called in (seems to be) is random.

    Therefore if the tool tip drawer gets called first, then Attribute A never gets to alter the Tool Tip's text, and the original Tool tip will display.
    And if Atribute A's drawer gets called first, it works as intended.

    Is there a solution for this.

    I understand there is an order parameter, this is for decoration drawers, and tool tip and Attribute A are not decoration.

    Additionally, the order which the attributes are called in seems to happen on compile.

    Furthermore the following code is identical
    Code (csharp):
    1.  
    2. [AttributeA]
    3. [tooltip]
    4. public float a;
    5.  
    6. [tooltip]
    7. [AttributeA]
    8. public float b;
    9.  
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I wound up using an index. Headache Gone! ;D

     
  3. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    But This means I would make my own read only attribute :(

    I guess it [mytooltip(...)] wouldn't do anything (no or empty drawer). The only purpose would be to store a string which [AttributeA] would then get the string and set the tooltip on the property.
     
    Last edited: May 10, 2016