调整音乐

using UnityEngine;
using System.Collections;

public class ChangeMusic : MonoBehaviour 
{
    //public GameObject music;
    UISlider uis_music;
    
    public GameObject music;
    AudioSource a;
    
    void OnSliderChange()
    {
        //Debug.Log("Music");
        
        //ConstantData.MUSIC_VOLUME
        
        if(uis_music!=null)
        {    
            ConstantData.MUSIC_VOLUME = uis_music.sliderValue;
            
            if(a == null)
            {
                a = music.GetComponent<AudioSource>();
            }
            
            a.volume = ConstantData.MUSIC_VOLUME;
        }
    }
    
    // Use this for initialization
    void Start () 
    {
        uis_music = GetComponent<UISlider>();
            
        uis_music.sliderValue = ConstantData.MUSIC_VOLUME;
        
        a = music.GetComponent<AudioSource>();
    }
    
    
}

 

posted @ 2013-10-29 14:48  小薇林  阅读(166)  评论(0编辑  收藏  举报