Search Unity

Button Hover styles ignored?

Discussion in 'Immediate Mode GUI (IMGUI)' started by sybixsus2, Jan 7, 2010.

  1. sybixsus2

    sybixsus2

    Joined:
    Feb 16, 2009
    Posts:
    943
    I'm trying to apply a custom GUIStyle to a GUIButton, but I can't seem to set any hover properties. I have the normal textcolor set to white and this works, but all the other textcolors, for active, hover, onhover, onactive, etc are all black. When I hover over the button, it never changes the textcolor to black.

    What am I missing?
     
  2. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Nothing jumps out as that should certainly work. How are you applying the custom style to your button? Can you show your code?
     
  3. sybixsus2

    sybixsus2

    Joined:
    Feb 16, 2009
    Posts:
    943
    Well I have the GUIStyle as a public member of the behaviour class, so that's defined in the property inspector.

    http://www.starsentineltactics.com/temp/gui.jpg

    So then all I do in OnGUI is this:

    Code (csharp):
    1.  
    2. if (GUI.Button(r, workingNodes[0].getContent(), buttonStyle))
    3.                 {
    4.                     ProcessDialogueTreeNode(currentNode);
    5.                 }
    6.  
     
  4. sybixsus2

    sybixsus2

    Joined:
    Feb 16, 2009
    Posts:
    943
    Having played around with this some more, it seems that the problem happens because I haven't defined textures for the other styles. Is that intended behaviour or a bug?

    I can see that having transparent pixels in a texture not trigger the hover style could make good sense, but if I don't supply a texture then the hover style will never trigger. Also, it seems inconsistent as the button still registers a click if I click the mouse button. Either Unity accepts that my mouse is "over" the button or it does not.
     
  5. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    It's intended. Unfortunately, there isn't any way to apply the same custom style across all the different states - you have to set them all separately
     
  6. sybixsus2

    sybixsus2

    Joined:
    Feb 16, 2009
    Posts:
    943
    I didn't want to apply the same custom style across all the different states. I actually wanted not to use a texture for the background of the hover style, and only to show the text.

    What I'm saying is that without a texture the entire hover style is ignored. It's inconsistent that the hover style should be ignored and yet the button remains clickable. If not having a texture is intended to stop the button registering a hover, it should not register a click either. If it's intended to register a click, it should register a hover too.
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    I see. Have you filed a bug report about this?
     
  8. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
  9. SomeRandomGuy

    SomeRandomGuy

    Joined:
    Jul 4, 2012
    Posts:
    11
    Still having this bug, when using a GUIStyle without a background image I don't get any states besides the normal state. The last post here(saying a bug report was sent) was in 2010, so why has this not been fixed yet? I know adding a 1x1 px transparent texture fixes it, but I still think this should be properly fixed.
     
  10. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
  11. Bloody-Swamp

    Bloody-Swamp

    Joined:
    Jul 30, 2012
    Posts:
    38
    2014, after 4 years(!!!) and this bug is still there!!!... (v.4.3.4)
    After the arrival of the new GUI, the OnGUI will still be supported, right? So, that bug should be fixed!
     
    Last edited: Apr 28, 2014
  12. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54