Ok my buddy was kind enough to email it to me. Keep in mind this was designed for a horizontal slider for volume control on an android. There is code to handle mouse down and finger touch. You should be able to figure out what you need from it. Enjoy!
using UnityEngine;
using System.Collections;
public class SliderScript : MonoBehaviour
{
public float min_X;
public float max_X;
public string prefsString;
private float m_Volume = 0.0f;
float originalWidth = 1280.0f; // define here the original resolution
float originalHeight = 800.0f; // you used to create the GUI contents
Vector3 scale;
private bool handleFingerInput = false;
void Awake ()
{
m_Volume = PlayerPrefs.GetFloat(prefsString);
float xpos = min_X + ((max_X - min_X) * m_Volume);
gameObject.transform.position = new Vector3(xpos, gameObject.transform.position.y, gameObject.transform.position.z);
}
// Use this for initialization
void Start ()
{
scale.x = Screen.width/originalWidth; // calculate hor scale
scale.y = Screen.height/originalHeight; // calculate vert scale
scale.z = 1;
}
// Update is called once per frame
void Update ()
{
if(gameObject.transform.position.x <= min_X)
{
gameObject.transform.position = new Vector3(min_X, gameObject.transform.position.y, gameObject.transform.position.z);
}
else if(gameObject.transform.position.x >= max_X)
{
gameObject.transform.position = new Vector3(max_X, gameObject.transform.position.y, gameObject.transform.position.z);
}
if(Input.touchCount > 0)
{
for(int i = 0; i < Input.touchCount; i++)
{
Vector2 inputPosition = Input.touches*.position;*
_ if (Input.touches*.phase == TouchPhase.Began )_
_ {*_
* if(guiTexture.HitTest(inputPosition) == true)*
* {*
* handleFingerInput = true;*
* }*
* }*
else if((Input.touches_.phase == TouchPhase.Moved || Input.touches*.phase == TouchPhase.Stationary) && (handleFingerInput == true))
{
float xpos = gameObject.transform.position.x;
xpos = inputPosition.x / Screen.width;_
if(xpos <= min_X)
_ {_
xpos = min_X;
_ }_
else if(xpos >= max_X)
_ {_
xpos = max_X;
_ }*_
* gameObject.transform.position = new Vector3(xpos, gameObject.transform.position.y, gameObject.transform.position.z);*
* m_Volume = (xpos - min_X) / (max_X - min_X);*
* if(PlayerPrefs.GetFloat(prefsString) != m_Volume)
_ {_
PlayerPrefs.SetFloat(prefsString, m_Volume);
_ PlayerPrefs.Save();
}
}
else*
* {
handleFingerInput = false;
}*_
* }*
* }*
* }*
* void OnMouseDown()*
* {*
* StartCoroutine(“HandleMouseDown”);*
* }*
* IEnumerator HandleMouseDown()*
* {*
* while(Input.GetMouseButtonUp(0) == false)*
* {*
* Vector3 inputPosition = Input.mousePosition;*
* float xpos = gameObject.transform.position.x;*
* xpos = inputPosition.x / Screen.width;*
* if(xpos <= min_X)
_ {_
xpos = min_X;
_ }_
else if(xpos >= max_X)
_ {_
xpos = max_X;
_ }*_
* gameObject.transform.position = new Vector3(xpos, gameObject.transform.position.y, gameObject.transform.position.z);*
* m_Volume = (xpos - min_X) / (max_X - min_X);*
* if(PlayerPrefs.GetFloat(prefsString) != m_Volume)
_ {_
PlayerPrefs.SetFloat(prefsString, m_Volume);
_ PlayerPrefs.Save();
}*_
* yield return null;*
* }*
* }*
}