Search Unity

Curved Slider?

Discussion in 'Immediate Mode GUI (IMGUI)' started by FranklyMyDear, Aug 5, 2012.

  1. FranklyMyDear

    FranklyMyDear

    Joined:
    Aug 2, 2012
    Posts:
    52
    I'm guessing the answer to this is NO, but if you don't ask you will never know

    Is it possible to create a slider that is Curved, i want to simulate walking up to a building
    and then with the GUI (a semi circle slider or quadrant) sliding around to the left or right
    of the building

    Thanks
    Michael
     
  2. ModStoryGames

    ModStoryGames

    Joined:
    Apr 27, 2012
    Posts:
    179
    It is possible. It would require some math, though. It might be easier if you are using NGUI or one of the other GUI packages, but in Unity GUI you just need to calculate a handle position along a curve based on its value.

    [Sorry I don't have an example. Bit rushed, atm.]
     
  3. felipedejesus145

    felipedejesus145

    Joined:
    Nov 22, 2012
    Posts:
    7
    hi there, it is possible indeed. I just had the same need a few days ago, and ended up coding this:

    Code (JavaScript):
    1. hSliderValue = GUI.HorizontalSlider (Rect (940, 135+(Mathf.Sin(hSliderValue*-.0175)*30), 243, 30), hSliderValue, 0.0, 180.0);
    this script uses a Sin wave to simulate the curvature of a slider. It wont be useful for a full circle slider though. Only useful for semi circles or waves.
     
    Iresh likes this.