public bool soundCall(SOUND_CH _ch, AudioClip _clip, float _volRate = 1.0f, bool _isOneShot = false)
    {
        float vol = getChannelVolume(_ch);

        if (_isOneShot)
        {
            if (_clip == null)
            {
                return(false);
            }
            sysAudioSource[(int)_ch].PlayOneShot(_clip, vol * _volRate);
        }
        else
        {
            if (_clip != null)
            {
                sysAudioSource[(int)_ch].Stop();
            }
            sysAudioSource[(int)_ch].volume = vol * _volRate;
            if (_clip != null)
            {
                sysAudioSource[(int)_ch].clip = _clip;
                sysAudioSource[(int)_ch].Play();
            }
        }
        return(true);
    }
Example #2
0
 //---------------------------------------------------------
 public float getChannelVolume(SOUND_CH _ch)
 {
     float vol=1.0f;
     switch(_ch){
         case SOUND_CH.SE:    vol = mSysData.volumeSe;    break;
         case SOUND_CH.BGM:   vol = mSysData.volumeBgm;   break;
         case SOUND_CH.VOICE: vol = mSysData.volumeVoice; break;
     }
     return vol;
 }
    //---------------------------------------------------------
    public bool soundCall(SOUND_CH _ch, int _sysClipId, float _volRate = 1.0f, bool _isOneShot = false)
    {
        bool ret = false;

        if ((sysSeList != null) && (sysSeList.clipList.Length > _sysClipId))
        {
            ret = soundCall(_ch, sysSeList.clipList[_sysClipId], _volRate, _isOneShot);
        }
        return(ret);
    }
    //---------------------------------------------------------
    public float getChannelVolume(SOUND_CH _ch)
    {
        float vol = 1.0f;

        switch (_ch)
        {
        case SOUND_CH.SE:    vol = mSysData.volumeSe;    break;

        case SOUND_CH.BGM:   vol = mSysData.volumeBgm;   break;

        case SOUND_CH.VOICE: vol = mSysData.volumeVoice; break;
        }
        return(vol);
    }
    //---------------------------------------------------------
    public float setChannelVolume(SOUND_CH _ch, float _rate, bool _isAutoSave = true)
    {
        float vol = getChannelVolume(_ch);

        _rate = Mathf.Clamp01(_rate);
        switch (_ch)
        {
        case SOUND_CH.SE:    mSysData.volumeSe = _rate;    break;

        case SOUND_CH.BGM:   mSysData.volumeBgm = _rate;;   break;

        case SOUND_CH.VOICE: mSysData.volumeVoice = _rate; break;
        }
        if (_isAutoSave)
        {
            saveSysData();
        }
        return(vol);
    }
Example #6
0
 //---------------------------------------------------------
 public void soundStop(SOUND_CH _ch)
 {
     sysAudioSource[(int)_ch].Stop();
 }
Example #7
0
 public bool soundCall(SOUND_CH _ch, AudioClip _clip, float _volRate=1.0f, float _oneShotRate=0.0f)
 {
     float vol=getChannelVolume(_ch);
     AudioSource source = sysAudioSource[(int)_ch];
     if(_oneShotRate>=1.0f){
         if(_clip==null)	return false;
         source.PlayOneShot(_clip,vol * _volRate);
     }else{
         if((_oneShotRate>0.0f)&&source.isPlaying&&(source.clip!=null)){
             if((source.time/source.clip.length)<(_oneShotRate)){
                 return false;
             }
         }
         sysAudioSource[(int)_ch].volume = vol * _volRate;
         if(_clip!=null){
             source.Stop();
             source.clip = _clip;
             source.Play();
         }
     }
     return true;
 }
Example #8
0
 //---------------------------------------------------------
 public bool soundCall(SOUND_CH _ch, int _sysClipId, float _volRate=1.0f, float _oneShotRate=0.0f)
 {
     bool ret = false;
     if( (sysSeList!=null) && (sysSeList.clipList.Length > _sysClipId) ){
         ret = soundCall(_ch, sysSeList.clipList[_sysClipId], _volRate, _oneShotRate);
     }
     return ret;
 }
Example #9
0
 //---------------------------------------------------------
 public float setChannelVolume(SOUND_CH _ch,float _rate, bool _isAutoSave=true)
 {
     float vol=getChannelVolume(_ch);
     _rate = Mathf.Clamp01(_rate);
     switch(_ch){
         case SOUND_CH.SE:    mSysData.volumeSe = _rate;    break;
         case SOUND_CH.BGM:   mSysData.volumeBgm = _rate;;   break;
         case SOUND_CH.VOICE: mSysData.volumeVoice = _rate; break;
     }
     if(_isAutoSave){
         saveSysData();
     }
     return vol;
 }
 //---------------------------------------------------------
 public void soundStop(SOUND_CH _ch)
 {
     sysAudioSource[(int)_ch].Stop();
 }