UI how implemntasi UI slider to UI new for unity 4.6

using UnityEngine;
using System.Collections;

public class ZoomObject : MonoBehaviour {

private float hsliderval=1.0f;
public GameObject objek;

// Use this for initialization
void Start () {
	
	hsliderval = 1.0f;
	
}

// Update is called once per frame
void Update () {

	objek.transform.localScale = new Vector3(0.55f, 0.55f, 0.55f) * hsliderval * 0.1f;
	
}

void OnGUI()
{
	hsliderval = GUI.HorizontalSlider(new Rect(25, 25, 80.0f,10.0f) , hsliderval,1.0f, 30.0f);

	
}

}

1 Answer

1

The Script :

using UnityEngine; 
using UnityEngine.UI; 
using System.Collections;

public class ZoomObject : MonoBehaviour {
	
	private float hsliderval = 1.0f;
	public GameObject objek;
	public Slider slider;  //assign it in Inspector or initialize it in Start() or Awake()

	void Start () {
		hsliderval = 1.0f;
	}

	public void sliderT(){ //needs to be public
		hsliderval = slider.value;
	}

	void Update () {
		objek.transform.localScale = new Vector3(0.55f, 0.55f, 0.55f) * hsliderval * 0.1f;
		
	}
}

Slider :
Slider

ZoomObject :
ZoomObject

Heey, I got exactly the same problem. I have a Nexus 5 with Android 5.1.1 I tried logcat but couldn't find anything yet