Author Topic: NGUI Volume. Slider  (Read 2474 times)

easy_peasy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
NGUI Volume. Slider
« 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! (=

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Volume. Slider
« Reply #1 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.