unity ngui help

Hi guys,

I’m having some difficulty trying to make an audio scrubber using ngui, I have managed to do it using unity gui but I need to get it implemented using ngui. Heres my gui code:

void OnGUI()
	{
		GUI.color = Color.black;

		if(AudioControllers.musicPlaying == true  AudioControllers.pauseMusic == false)
		{
			scrollPos = GUI.HorizontalSlider(new Rect(Screen.width / 4, Screen.height - 100f, Screen.width / 2, 50f), scrollPos, 0, mainMusic.clip.length);
			
			if(GUI.changed == true)
			{
				moved = true;
			}
			
			if(GUI.changed == false  !Input.GetMouseButton(0)  moved == false)
			{
				scrollPos = mainMusic.time;
			}
			
			if(Input.GetMouseButtonUp(0)  moved == true)
			{
				mainMusic.time = scrollPos;
				moved = false;
			}
		}

		GUI.Label(new Rect(0f, 0f, 100f, 50f), (mainMusic.time).ToString());

Any help would be appreciated. I’ve managed to get the bar moving along with the audio using ngui and thats about it.

If I may suggest, you’re more likely to get good on NGUI from the NGUI support forum:

I’ve seen a lot of good information over there, including answers from the developer of NGUI.

Thanks I’ll check it out and hopefully get it sorted!

Hi again,

I’ve almost finished getting this audio done but what I need to do is change the actual time of a second so its read differently is there anyway in which this can be done?

Thanks

I’ve managed to get it working if anybody needs any help heres what I did using ngui:

public UIScrollBar scrollBar;
	public AudioSource mainMusic;

	void Update()
	{
		if(AudioControllers.musicPlaying == true  AudioControllers.pauseMusic == false)
		{
			scrollBar.value += 1 / mainMusic.clip.length * Time.deltaTime;
			
			if(Input.GetMouseButtonUp(0))
			{
				mainMusic.time = scrollBar.value * mainMusic.clip.length; 
			}
		}
	}