// Start is called before the first frame update void Start() { if (controller == null) { controller = gameObject.AddComponent <AudioSourceController>(); } }
void StartChargeDownSound() { if (SoundManager.instance != null) { chargeDownWeaponAudioController = SoundManager.instance.PlaySFX(chargeDownSound); } }
public static void PlaySound(string name, GameObject gameObject) { if (!Instance.soundDictionary.ContainsKey(name)) { Debug.LogError("The sound named <color=blue>" + name + "</color> doesn't exists."); return; } if (Instance.gameObjectDictionary.ContainsKey(gameObject)) { AudioSourceController audioSourceControlle = Instance.gameObjectDictionary[gameObject]; PlaySoundInternal(name, audioSourceControlle); } else { GameObject audioSource = new GameObject("Audio Source Controller"); audioSource.transform.SetParent(gameObject.transform, true); AudioSourceController audioSourceController = audioSource.AddComponent <AudioSourceController>(); audioSourceController.Initialize(Instance.numberChannelPerGameObject); Instance.gameObjectDictionary.Add(gameObject, audioSourceController); PlaySoundInternal(name, audioSourceController); } }
public void PutController(AudioSourceController controller) { if (_pool.Contains(controller) == false) { _pool.Add(controller); } }
protected override void OnTouch() { Squish(); AudioSource audio = AudioSourceController.GetAudioSourceController().GetComponent <AudioSource>(); audio.PlayOneShot(floaterSound, soundVolume); }
public AudioSourceController Play(Transform parent) { AudioSourceController controller = Play(parent.position); controller.ParentTransform = parent; return(controller); }
// Start is called before the first frame update void Start() { if (audioSourceController == null) { audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } }
private AudioSourceController ReturnNewAudioSourceController(AUDIO_SOURCE_TYPE audioSourceType) { GameObject newAudioSource = null; AudioSourceController newAudioSourceController = null; switch (audioSourceType) { case AUDIO_SOURCE_TYPE.MUSIC: newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("MusicAudioSource", Vector3.zero, Quaternion.identity); break; case AUDIO_SOURCE_TYPE.SOUND_EFFECT: newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("SoundEffectAudioSource", Vector3.zero, Quaternion.identity); break; case AUDIO_SOURCE_TYPE.DIALOGUE: newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("DialogueAudioSource", Vector3.zero, Quaternion.identity); break; } newAudioSourceController = newAudioSource.GetComponent <AudioSourceController>(); return(newAudioSourceController); }
//显示字条。 itemName道具名,showTime淡入/淡出时间,间隔waitTime后再显示关闭按钮 public void Show(string itemName, float showTime = 0.5f, float waitTime = 2f, int count = 2) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } if (itemName == "收音机") { m_AudioSourceController.Play("收音机杂音循环", transform); } else { m_AudioSourceController.Play("阅读字条", transform); } transform.Find("Canvas/Close Button").gameObject.SetActive(false); if (itemName != "收音机" && itemName != "收据1") { transform.Find("Canvas/Note Text").GetComponent <Text>().text = GameObject.Find("ItemsData").GetComponent <ItemsData>().GetItemByItemName(itemName).introduce; } if (itemName == "纸条" || itemName == "日记") { transform.Find("Canvas/Note Text").GetComponent <Text>().fontSize = 26; } GetComponent <ShowAndHideUI>().Show(showTime, delegate() { StartCoroutine(IE_ShowButton(1f, itemName, count)); }); //禁用输入 InputController.BanButton(true); InputController.BanMouse(true); GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = false; }
public AudioSourceController GetController() { if (SFX_ANCHOR == null) { GameObject go = new GameObject("_SFXAnchor"); SFX_ANCHOR = go.transform; //go.transform.SetParent(this.transform); } AudioSourceController output = null; if (_pool.Count > 0) { output = _pool[0]; _pool.Remove(output); return(output); } else { GameObject go = new GameObject("AudioController"); output = go.AddComponent <AudioSourceController>(); if (mixer != null) { output.GetComponent <AudioSource>().outputAudioMixerGroup = mixer.FindMatchingGroups("SFX")[0]; } go.transform.SetParent(SFX_ANCHOR, true); return(output); } }
private IEnumerator Start() { if (this._playOnStart) { AudioSourceController audioSourceController = this._audioSourcePlayer.AquireAudioSourceController(); //! Calling `Play` each iteration. do { audioSourceController.Play( audioClip: this._audioClip ); yield return(new WaitForSecondsRealtime(this._audioClip.length)); }while (this._loop); ObjectPool.Instance.Release(audioSourceController); //? How to do it without calling `Play` each iteration? //? Why is it not recommended in this cae? //!? Because you are modifything a state of an entity that has been pooled. //!? It sure seems an easier and a better choice, but it may lead to unexpected bugs like something playing again when it shouldn't have. //audioSourceController.AudioSource.loop = this._loop; //audioSourceController.Play( // audioClip: this._audioClip //); //yield return new WaitForSecondsRealtime(this._audioClip.length); } }
private void Start() { _resetDelay = Mathf.Clamp(_resetDelay, 0f, float.MaxValue); _audioSourceController = GetComponent <AudioSourceController>(); _renderer = GetComponent <Renderer>(); _rigidbody = GetComponent <Rigidbody>(); }
void Start() { GetTerrainProps(); audioController = GetComponent <AudioSourceController>(); wheelSmokeParticleSystem = GetComponent <ParticleSystem>(); carController = GetComponentInParent <CarController>(); }
void StopChargeDownSound() { if (chargeDownWeaponAudioController != null) { chargeDownWeaponAudioController.StopPlaying(); chargeDownWeaponAudioController = null; } }
void Start() { if (!audioCategory.IsMuted) { sceneSongController = sceneSong.Play(); } gameEndEvent.RegisterListener(stopSceneSong); }
private static void PlaySoundInternal(string name, AudioSourceController audioSourController) { Sound sound = Instance.soundDictionary[name]; AudioClip audioClip = sound.clips[Random.Range(0, sound.clips.Length)]; float volume = sound.volume + Random.Range(-sound.volumeVariance, sound.volumeVariance); float pitch = sound.pitch + Random.Range(-sound.pitchVariance, sound.pitchVariance); audioSourController.PlaySound(audioClip, volume, pitch); }
public void Play(AudioSourceController source, float currentSfx) { if (clip == null || source == null) { return; } source.Play(clip, volume * currentSfx, pitch); }
private void Start() { last_time = 0f; is_Cough = false; child = transform.GetChild(0).gameObject; if (audioSourceController == null) { audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } }
private void FinishCough() { InputController.BanButton(false); child.GetComponent <Animator>().SetBool("IsCough", false); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); last_time = 0f; is_Cough = false; InputController.GetKey(); }
//public void PlayUI(AudioClip audioClip) //{ // AudioSourceController audioSourceController = ObjectPool.Instance.Aquire<AudioSourceController>( // poolable: this._audioSourceControllerPrefab // ); // audioSourceController.Play(audioClip: audioClip); //} public AudioSourceController Play(AudioClip audioClip) { AudioSourceController audioSourceController = ObjectPool.Instance.Aquire <AudioSourceController>( poolable: this._audioSourceControllerPrefab ); audioSourceController.Play(audioClip: audioClip); return(audioSourceController); }
public AudioSourceController Play() { AudioSourceController controller = AudioPoolManager.Instance.GetController(); controller.SetSourceProperties(GetClip(), volume, pitch, loop, spacialBlend); controller.Category = Category; controller.Play(); return(controller); }
private IEnumerator PlayProcess() { AudioSourceController audioSourceController = this._audioSourcePlayer.Play( audioClip: this._audioClip ); yield return(new WaitForSecondsRealtime(this._audioClip.length)); ObjectPool.Instance.Release(audioSourceController); }
public void StartForeshadowing(AudioCueType cueType) { if (StateManager.State == GameState.Playing) { AudioSource foreshadow = gameObject.AddComponent <AudioSource>(); SyncSourceSettings(audio, ref foreshadow); MusicWithInformation foreshadowTrack; if (cueType == AudioCueType.Foreshadow_Long) { foreshadowTrack = foreshadowTracksLong[0]; CycleList(ref foreshadowTracksLong); } else if (cueType == AudioCueType.Foreshadow_Short) { foreshadowTrack = foreshadowTracksShort[0]; CycleList(ref foreshadowTracksShort); } else { return; } foreshadow.clip = foreshadowTrack.clip; foreshadow.volume = foreshadowTrack.volume; double initTime = GetTimeOfNextBar(); foreshadow.PlayScheduled(initTime); foreshadow.SetScheduledStartTime(initTime); AudioSourceController controller = new AudioSourceController(initTime, foreshadow, foreshadowTracksLong[0].cueType); foreshadowSourceControllers.Add(controller); int id = foreshadowID++; //EventManager.Music_ForeshadowBegin(id, foreshadow.clip.length); double currentBeatDuration = 60.0 / (currentlyPlayingTrack.BPM); if (cueType == AudioCueType.Foreshadow_Long) { StartCoroutine(CallForeshadowBegin(initTime - AudioSettings.dspTime, id, currentBeatDuration * 8)); StartCoroutine(CallForeshadowEvent(initTime - AudioSettings.dspTime + currentBeatDuration * 8, id, foreshadow.clip.length)); } else if (cueType == AudioCueType.Foreshadow_Short) { StartCoroutine(CallForeshadowBegin(initTime - AudioSettings.dspTime, id, currentBeatDuration * 4)); StartCoroutine(CallForeshadowEvent(initTime - AudioSettings.dspTime + currentBeatDuration * 4, id, foreshadow.clip.length)); } else if (controller.cueType == AudioCueType.UNDEFINED) { Debug.LogWarning("Tried to activate a foreshadow countdown but the clip had the UNDEFINED cue type"); } } }
public void GetSkill() { AudioSourceController audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); audioSourceController.Play("修理轮椅", transform); m_Disable = false; GetComponent <ShowAndHideUI>().Show(); GetComponent <Image>().sprite = normalSprite; GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f); transform.GetChild(0).GetComponent <Image>().color = new Color(1, 1, 1, 0); }
//Button继续游戏 public void ContinueButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); Debug.Log("Continue"); }
public void MusicButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); transform.Find("PauseCanvas/BackgroundPanel/BasicPanel").gameObject.SetActive(false); transform.Find("PauseCanvas/BackgroundPanel/MusicPanel").gameObject.SetActive(true); }
//Button退出 public void ExitButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); Application.Quit(); Debug.Log("Exit"); }
public AudioSourceController Play(Vector3 position) { controller = AudioPoolManager.Instance.GetController(); float volGen = AudioUtils.DecibelToLinear(Volume + Random.Range(RandomVolume, 0)); float pitchVar = (RandomPitch / 2); float pitchGen = AudioUtils.St2pitch(Random.Range(Pitch - pitchVar, Pitch + pitchVar)); controller.SetSourceProperties(GetClip(), volGen, pitchGen, Loop, SpatialBlend); controller.SetPosition(position); controller.Play(); return(controller); }
//Button开始新游戏 public void NewStartButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); SceneManager.LoadScene(1); //加载场景1 Debug.Log("NewStart"); }
void Start() { ASC_Ambient = GetComponent <AudioSourceController>(); MM = GameObject.FindWithTag("MenuManager").GetComponent <MenuManager>(); Event.SetActive(true); PlayAmbient(); QualitySettings.vSyncCount = 0; Application.targetFrameRate = 60; SceneManager.sceneLoaded += OnSceneLoaded; }