Exemplo n.º 1
0
    public static void PlayAudioOneShot(AudioSource audioSource, int soundId, float volume = 1f)
    {
        if (_globalAudioVolume <= 0 || _audioVolume <= 0)
        {
            return;
        }

        SoundDeploy deploy = _soundTableT.GetSection(soundId);

        if (!deploy || string.IsNullOrEmpty(deploy.resource))
        {
            return;
        }

        AudioClip resource;

        if (CachePool.TryGetValue(deploy.resource, out resource))
        {
            PlayAudioOneShot(audioSource, resource, volume, deploy.volume);
        }
        else
        {
            RLoadPlayAudioOneShot(deploy.resource, audioSource, volume, deploy.volume);
        }
    }
Exemplo n.º 2
0
 public static void UnloadSoundAsset(AudioSource audioSource, int soundId)
 {
     if (audioSource != null)
     {
         SoundDeploy deploy = _soundTableT.GetSection(soundId);
         CachePool.Remove(deploy.resource);
         Resources.UnloadAsset(audioSource.clip);
     }
 }
Exemplo n.º 3
0
    public static void PlayEnvironmentMusic(int id, bool loop = true, float fade = 1f)
    {
        SoundDeploy deploy = _soundTableT.GetSection(id);

        if (!deploy)
        {
            return;
        }
        PlayEnvironmentMusic(deploy.resource, loop, deploy.volume, fade);
    }
Exemplo n.º 4
0
    public static void Load(int id, Action <SoundClip> notify)
    {
        SoundDeploy deploy = _soundTableT.GetSection(id);

        if (!deploy || string.IsNullOrEmpty(deploy.resource))
        {
            return;
        }
        Load(deploy.resource, deploy.volume, notify);
    }
Exemplo n.º 5
0
    public static void PlayMusic(int id, bool loop = true, float fade = 1f, string tag = "")
    {
        SoundDeploy deploy = _soundTableT.GetSection(id);

        if (!deploy)
        {
            return;
        }

        PlayMusic(deploy.resource, tag, loop, deploy.volume, fade);
    }
Exemplo n.º 6
0
    private static void LoadPlayAudio(int id, AudioSource audioSource, bool loop, Action playCallBack)
    {
        if (!loop && (_globalAudioVolume <= 0 || _audioVolume <= 0))
        {
            return;
        }

        SoundDeploy deploy = _soundTableT.GetSection(id);

        if (!deploy || string.IsNullOrEmpty(deploy.resource))
        {
            return;
        }
        LoadPlayAudio(deploy.resource, audioSource, deploy.volume, loop, playCallBack);
    }