private bool GetAudioClip(string soundName, out AudioClipController audio, float volumePercent = 1)
    {
        for (int index = 0; index < MusicAudioClip.Length; index++)
        {
            var audioInfo = MusicAudioClip[index];
            if (audioInfo.ClipName == soundName)
            {
                audio = InstanceAudioClip(audioInfo);
                audio.AudioSource.volume = MusicVolume*volumePercent;
                musicList.Add(audio);
                return true;
            }
        }

        for (int index = 0; index < EffectsAudioClip.Length; index++)
        {
            var audioInfo = EffectsAudioClip[index];
            if (audioInfo.ClipName == soundName)
            {
                audio = InstanceAudioClip(audioInfo);
                audio.AudioSource.volume = EffectVolume*volumePercent;
                effectList.Add(audio);
                return true;
            }
        }
        audio = null;
        return false;
    }
 private void OnClipEnded(AudioClipController obj)
 {
     if (effectList.Remove(obj))
     { 
         obj.OnAudioEnded -= OnClipEnded;
         Destroy(obj.gameObject);
     }
 }
 public void PlaySound(string soundName, float volumePercent = 1)// todo refact
 {
     AudioClipController sound = null;
     if (GetAudioClip(soundName, out sound, volumePercent))
     {
         sound.Play();
     }
 }
 public void PlaySound(string soundName, int count)// todo refact
 {
     AudioClipController sound = null;
     if (GetAudioClip(soundName, out sound))
     {
         sound.Play(count);
     }
     
 }
        public override async void Init(GameObject gameObject)
        {
            base.Init(gameObject);

            audioSource.loop   = false;
            audioSource.volume = 0.2f;

            clipController = new AudioClipController();
            await clipController.LoadAudioClipWithWebRequest(audioClipPath, AudioType.WAV);
        }
Ejemplo n.º 6
0
    public AudioManager(GameObject gameObject, int audioNum = 1)
    {
        for (int i = 0; i < audioNum; i++)
        {
            AudioSource audioSource = gameObject.AddComponent <AudioSource>();
            audioSources.Add(audioSource);
        }

        clipController = new AudioClipController();
    }
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        if (instance != null)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }
    }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    async void Start()
    {
        AudioSource audioSource = gameObject.AddComponent <AudioSource>();

        AudioClipController controller = new AudioClipController();
        await controller.LoadAudioClipWithWebRequest(TEST_EFFECT_PATH, AudioType.WAV);

        controller.SetFadeOutCurve();

        audioSource.clip = controller.GetAudioClip();

        audioSource.Play();
    }
        public async void AdjustPitchForCutEffect()
        {
            return;

            Logger.log.Error("AdjustPitchForCutEffect");

            player.SetPitch(1f); //must initialize

            IDifficultyBeatmap        diffBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;
            CustomPreviewBeatmapLevel customPreviewBeatmapLevel = diffBeatmap.level as CustomPreviewBeatmapLevel;

            if (customPreviewBeatmapLevel != null)
            {
                string customLevelPath = customPreviewBeatmapLevel.customLevelPath;
                string songFileName    = customPreviewBeatmapLevel.standardLevelInfoSaveData.songFilename;
                string filepath        = customLevelPath + "\\" + songFileName;
                Logger.log.Error("custom level path = " + filepath);

                AudioClipController customSong = new AudioClipController();
                await customSong.LoadAudioClipWithWebRequest(filepath, AudioType.OGGVORBIS);
            }
        }
Ejemplo n.º 10
0
 public virtual void SetAudioClip(AudioClipController controller)
 {
     audioSource.clip = controller.GetAudioClip();
 }