Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Assigning custom style to GUI.VerticalScrollbar

Discussion in 'Immediate Mode GUI (IMGUI)' started by Adherbal, Aug 1, 2013.

  1. Adherbal

    Adherbal

    Joined:
    Dec 4, 2012
    Posts:
    12
    I'm trying to modify the looks of a VerticalScrollbar element by assigning it a custom style:

    Code (csharp):
    1. public GUIStyle scrollBarStyle;
    2. ...
    3.  
    4. scrollPosition = GUI.VerticalScrollbar(new Rect(0, 0, 24, 200), scrollPosition , 10, 0, 10, scrollBarStyle);
    This triggers warnings such as "Unable to find style 'downbutton' in skin 'GameSkin' Repaint".

    After googling for this problem I sort of understand it's looking for extra styles of the same name as the scrollbar style + "downbutton" but can't really figure out how to fix this. Note that - unless there is no other option - I'm working with custom GUIStyles (set up in the editor), not GUISkins.

    Can anyone shed some light on the easiest way to give a custom appearance to scroll bars?
     
  2. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    The current skin must have these extra styles defined.

    So, the line before your scrollbar, you must put in the GUI.skin call:

    Code (csharp):
    1. GUI.skin = _scrollerSkin;
    2. _scrollPosition = GUI.VerticalScrollbar(new Rect(0, 0, 24, 200), scrollPosition, 10, 0, 10); // no style here
    With that said, you don't need the overload with the style (as you did it), since the style could also be defined in the skin.
     
  3. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    any explanations on changing the skin style? Nothing I change seems to affect the bar