Created
June 24, 2016 07:34
-
-
Save unitycoder/a69c4ff5324336cfa33bde23c09d7397 to your computer and use it in GitHub Desktop.
SliderPingPong Handle Between Min-Max
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class SliderPingPong : MonoBehaviour | |
{ | |
public Slider slider; | |
public float speed = 1; | |
float pos = 0; | |
void Update() | |
{ | |
pos += speed * Time.deltaTime; | |
slider.value = Mathf.PingPong(pos, slider.maxValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment