Hi guys, I want to create an element with which you can control the volume of sound.
Create slider and attach code to it:
using UnityEngine;
using System.Collections;
public class UIVolumeControl : MonoBehaviour {
private UISlider _slider;
// Use this for initialization
void Start ()
{
_slider = gameObject.GetComponent<UISlider>();
_slider.sliderValue = AudioListener.volume ;
_slider.onValueChange += OnValueChange;
}
void OnValueChange(float val)
{
AudioListener.volume = val;
print(val);
}
}
Error occurs:
Assets/NGUI/Scripts/Interaction/UIPopupList.cs(313,43): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'
Many have this problem after upgrading Unity (4.3.0 use).
What's wrong? Why the error? Help! (=