コード例 #1
0
 public void Play(SFXData data)
 {
     this.data = data;
     _duration = 9999f;
     if (data.ReferencedClip.Asset != null)
     {
         OnLoaded(data.ReferencedClip.Asset as AudioClip);
     }
     else if (data.ReferencedClip.OperationHandle.IsValid())
     {
         if (data.ReferencedClip.OperationHandle.IsDone)
         {
             OnLoaded(data.ReferencedClip.OperationHandle.Result as AudioClip);
         }
         else
         {
             data.ReferencedClip.OperationHandle.Completed += h => OnLoaded(h.Result as AudioClip);
         }
     }
     else
     {
         try
         {
             data.ReferencedClip.LoadAssetAsync <AudioClip>().Completed += h => OnLoaded(h.Result);
         }
         catch (System.Exception) { }
     }
 }
コード例 #2
0
 public void Play(SFXData data, Transform parent)
 {
     Play(data);
     _source.spatialBlend = 1f;
     _transform.position  = parent.position;
     _toFollow            = parent;
 }
コード例 #3
0
 void ReleasePlayingClip(SFXData clip)
 {
     if (clip != null && _loadedClips.ContainsKey(clip))
     {
         _loadedClips[clip] = Mathf.Max(0, _loadedClips[clip]);
     }
 }
コード例 #4
0
 public void PlaySFX(SFXData SFXType)
 {
     if (SFXSource != null)
     {
         SFXSource.mute = !EssentialData.Instance.LoadSettingSFX();
         SFXSource.PlayOneShot(SFXClip[(int)SFXType - 1]);
     }
 }
コード例 #5
0
 public void Reset()
 {
     data = null;
     _source.Stop();
     _looping  = false;
     _elapsed  = 0f;
     _duration = 0f;
     _toFollow = null;
     _transform.localPosition = Vector3.zero;
     gameObject.SetActive(false);
     Id = -1;
 }
コード例 #6
0
ファイル: MusicPlayer.cs プロジェクト: JackSParrot/audio-pkg
        public void Play(string name)
        {
            if (_playingClip != null && string.Equals(name, _playingClip.ClipName, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }
            if (_playingClip != null)
            {
                _source.Stop();
                _playingClip.ReferencedClip.ReleaseAsset();
            }

            if (string.IsNullOrEmpty(name))
            {
                _playingClip = null;
                return;
            }
            var clip = _clipStorer.GetClipByName(name);

            _playingClip = clip;
            clip.ReferencedClip.LoadAssetAsync <AudioClip>().Completed += h => OnClipLoaded(h.Result);
        }
コード例 #7
0
 public void Play(SFXData data, Vector3 position)
 {
     Play(data);
     _source.spatialBlend = 1f;
     _transform.position  = position;
 }
コード例 #8
0
    private void Awake()
    {
        audioSource = gameObject.AddComponent <AudioSource>();

        settings = Resources.Load <SFXData>("SFXSettings");
    }