Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: easy_peasy on January 05, 2014, 10:21:52 AM

Title: NGUI Volume. Slider
Post by: easy_peasy on January 05, 2014, 10:21:52 AM
Hi guys, I want to create an element with which you can control the volume of sound.
Create slider and attach code to it:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class UIVolumeControl : MonoBehaviour {
  5.        
  6.         private UISlider _slider;
  7.        
  8.         // Use this for initialization
  9.         void Start ()
  10.         {
  11.                 _slider = gameObject.GetComponent<UISlider>();
  12.                 _slider.sliderValue =   AudioListener.volume ;
  13.                 _slider.onValueChange += OnValueChange;
  14.         }
  15.        
  16.         void OnValueChange(float val)
  17.         {
  18.                 AudioListener.volume = val;
  19.                 print(val);
  20.         }
  21. }

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! (=
Title: Re: NGUI Volume. Slider
Post by: ArenMook on January 05, 2014, 10:44:35 AM
You need to update your NGUI as well. Our line numbers don't match and NGUI doesn't use 'active' anywhere.