Search Unity

Slider Tick Marks

Discussion in 'Immediate Mode GUI (IMGUI)' started by ctsteve123, Aug 21, 2008.

  1. ctsteve123

    ctsteve123

    Joined:
    Sep 13, 2007
    Posts:
    51
    Would like to add tick marks and numbers to the GUI slider . Looked in the GUISkin and did not see this.
     
  2. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    You will probably have to put a new box with a background of ticks and numbers behind the slider... That would be a workaround anyway, I would think. I didnt get a chance to try though sense im at work right now... sorry
     
  3. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    read the docs. I forgot what the call the section on learning the gui, but at the end they teach you to extend the classes. Try something like this:

    Code (csharp):
    1.  
    2. function TickedSlider(area : Rect, min: int, max: int, val:int, tick : Texture2D)
    3. {
    4. var offSet : int = area.width / max;
    5. var tickSize : Rect = Rect(0,area.height / 3, area.width * 0.01, area.height * 0.3);
    6.  
    7. GUI.BeginGroup(area);
    8. for (x = 0; x <= area.width; x += offSet)
    9. {
    10. tickSize.x = x;
    11. GUI.DrawTexture(tickSize, tick);
    12. }
    13. GUI.EndGroup();
    14. GUI.Slider(adfakdjfa);
    15. }
    16.  
    Sorted...