Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

NGUI "Joystick" type of slider?

Discussion in 'Editor & General Support' started by DigitalAdam, Apr 9, 2013.

  1. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,192
    I would have posted it within the NGUI forum, but my account is still waiting for approval from the Admin.

    Is it possible to create a "joystick" type of slider, where it combines a horizontal and vertical slider in one, allowing limits? In the example I would like to be able to move the white dot around within the gray area, thus modifying 2 float variables for my morph.

    Thanks!
     

    Attached Files:

  2. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,192
    Or can you do this another way?
     
  3. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    within NGUI - i´m not sure.. but you can add a Box with NGUI, and a Dot (+ UIDragObject).

    And now check the distance of the Dot´s center, to the origin of the box. Like:

    Dot is on 22,56 inside the box, the boxs origin is on the upper left.
    so
    Slider X would have a percentage of ((22*100)/box.size_x), and Slider Y of ((56*100)/box.size_y)

    I think this way you could create your own Box Sliders :)
     
    Last edited: Apr 10, 2013
  4. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    Easy-peasy with eDriven.
     
  5. gdg

    gdg

    Joined:
    Jul 8, 2013
    Posts:
    18
    Hi, I think a way to do this would be using the dragobject script on a joystick sprite. You will have to then check distance to original position like Chaosgod_Espér says and then restric its movemnt in the dragobject script. A way to restric is already present there with bound clipping