Beispiel #1
0
    /// <summary>
    /// Initializes this instance.
    /// </summary>
    protected override void Awake()
    {
        base.Awake();

        _audioController = AudioController.Instance;
        //Debug.Log( "AudioObject.Awake" );

        audio.playOnAwake         = false;
        audio.clip                = null;
        category                  = null;
        _completelyPlayedDelegate = null;

        _lastChosenSubItemIndex  = -1;
        _fadeOutTotalTime        = -1;
        _fadeOutStartTime        = -1;
        _fadeInTotalTime         = -1;
        _fadeInStartTime         = -1;
        _playInitialTime         = -1;
        _volumeFromFade          = 1;
        _volumeFromScriptCall    = 1;
        _destroyIfNotPlaying     = false;
        _volumeExcludingCategory = 1;
        _paused                 = false;
        _applicationPaused      = false;
        _isCurrentPlaylistTrack = false;
        _stopClipAtTime         = 0;
        _startClipAtTime        = 0;

#if !UNITY_FLASH
        _setNextGaplessLoopingClipNextFrame = false;
#endif
    }
Beispiel #2
0
 void OnDestroy()
 {
     AudioItem = null;
     //此处代码保证结束回调不会被调用两次
     if (this._completelyPlayedDelegate != null)
     {
         _completelyPlayedDelegate(this);
     }
     this._completelyPlayedDelegate = null;
     //此方法PC环境会消耗13ms 暂时不使用;
     //Resources.UnloadAsset(_audioItem.AudioClip);
 }
Beispiel #3
0
    private void _SetReferences0()
    {
        _audioController        = null;
        primaryAudioSource.clip = null;

        if (secondaryAudioSource != null)
        {
            secondaryAudioSource.playOnAwake = false;
            secondaryAudioSource.clip        = null;
        }
        subItem  = null;
        category = null;
        _completelyPlayedDelegate = null;
    }
Beispiel #4
0
 /// <summary>
 /// 监视并给BGM绑定事件的方法,第一个参数为需要绑定的委托,第二个参数为BGM的名字(用于核对与当前播放的BGM是否匹配),第三个参数是绑定的时间
 /// 注意:该方法为临时绑定,不是永久绑定。也就是,每次绑定的方法触发过后,会自动将委托清空。
 /// </summary>
 /// <param name="hander"></param>
 /// <param name="name"></param>
 /// <param name="time"></param>
 public void LockBGMTimeEvent(AudioEventDelegate hander, string name, float time)
 {
     if (bg_Source.clip.name != name)
     {
         Debug.LogError("bgmName has error,playerChenck,NowBGM is " + bg_Source.clip.name + "   InputBGMName is" + name);
         return;
     }
     //if (bg_Source.time > time)
     //{
     //    Debug.LogError("needTime>bgmNowTime,playCheck!");
     //    return;
     //}
     audioDelegateDic.Add(dicIndex, new KeyValuePair <float, AudioEventDelegate> (time, hander));
     dicIndex++;
 }
Beispiel #5
0
    public void PlayEffect_Source(string name, AudioEventDelegate hander)
    {
        AudioClip clip = ResourcesManager.Instance.LoadAudioClip(name);

        if (clip == null)
        {
            Debug.LogError("clip is null");
            return;
        }
        if (clip != null)
        {
            effect_Source.clip = clip;
            effect_Source.loop = false;
            effect_Source.Play();
            OnEffectAudioPlayFinshed = hander;
            isEffectOnFished         = true;
        }
    }