Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created June 24, 2016 07:34
Show Gist options
  • Save unitycoder/a69c4ff5324336cfa33bde23c09d7397 to your computer and use it in GitHub Desktop.
Save unitycoder/a69c4ff5324336cfa33bde23c09d7397 to your computer and use it in GitHub Desktop.
SliderPingPong Handle Between Min-Max
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