public void PlayEffect(string effectName) { SoundEffect s = Array.Find(effects, effect => effect.name == effectName); // this uses a Lambda Expression int soundID = AndroidNativeAudio.play(s.fileID); AndroidNativeAudio.setVolume(soundID, s.volume * volumeControl.EffectsVolume); }
public void FreeContinueSFX() { if (GameManager.Sound) { freeContinueSID = AndroidNativeAudio.play(freeContinueFID); } }
private void Update() { if (!isShrinking) { this.transform.DOScale(new Vector3(0.51f, 0.51f, 0.51f), lifeSpan); } lifeSpan -= Time.deltaTime; if (lifeSpan < 0f && hasPlayed == false) { hasPlayed = true; SoundID = AndroidNativeAudio.play(FileID); } else if (lifeSpan <= 0f && lifeSpan > -1f) { if (!isShrinking) { isShrinking = true; this.transform.DOScale(new Vector3(0.0f, 0.0f, 1f), 0.3f); } } else if(lifeSpan <= -1f) { Destroy(this.gameObject); } }
public void ConfirmKnifeSFX() { if (GameManager.Sound) { confirmKnifeSID = AndroidNativeAudio.play(confirmKnifeFID); } }
public void UnlockKnifeSFX() { if (GameManager.Sound) { unlockKnifeSID = AndroidNativeAudio.play(unlockKnifeFID); } }
public void OnUnlockSFX() { if (GameManager.Sound) { onUnlockSID = AndroidNativeAudio.play(onUnlockFID); } }
public void RandomUnlockSFX() { if (GameManager.Sound) { randomUnlockSID = AndroidNativeAudio.play(randomUnlockFID); } }
public void WoodHitSFX() { if (GameManager.Sound) { woodHitSID = AndroidNativeAudio.play(woodHitFID); } }
public void AppleHitSFX() { if (GameManager.Sound) { appleHitSID = AndroidNativeAudio.play(appleHitFID); } }
public void LastHitSFX() { if (GameManager.Sound) { lastHitSID = AndroidNativeAudio.play(lastHitFID); } }
public void ThrowKnifeSFX() { if (GameManager.Sound) { throwKnifeSID = AndroidNativeAudio.play(throwKnifeFID); } }
//edited add whole fuctions below StreamID's public void KnifeHitSFX() { if (GameManager.Sound) { knifeHitSID = AndroidNativeAudio.play(knifeHitFID); } }
public void BossFightEndSFX() { if (GameManager.Sound) { bossFightEndSID = AndroidNativeAudio.play(bossFightEndFID); } }
public void PlaySound(int id, float volume = -1) { //if (cancelSound) // return; if (!isInitialized) { Initialize(); } if (volume == -1) { volume = m_Volume; } else { volume = volume * m_Volume; } #if UNITY_ANDROID && !UNITY_EDITOR if (bestPerformance) { PlayWithAudioSource(id, volume); } else { AndroidNativeAudio.play(id, volume); } #else PlayWithAudioSource(id, volume); #endif }
//public IEnumerator PlaySound(AudioSource source, Transform parent) //{ // Transform sourceTransform = source.transform; // sourceTransform.SetParent(null); // source.Play(); // do // { // yield return null; // } while (source.isPlaying); // sourceTransform.SetParent(parent); //} public void PlaySFX(string name) { string[] str = name.Split(':'); if (str.Length > 1) { float pitch; if (float.TryParse(str[1], out pitch)) { //Debug.Log("SFX:" + str[0] + pitch); PlaySFX(str[0], pitch); } else { Debug.LogErrorFormat("PlaySFX-Pitch Parsing False"); } return; } #if UNITY_EDITOR || UNITY_STANDALONE if (SFXClipDictionary.ContainsKey(name)) { SFX.PlayOneShot(SFXClipDictionary[name], sfxVolume); } #endif #if !UNITY_EDITOR && UNITY_ANDROID currentSFXStreamID = AndroidNativeAudio.play(SFXFileIDDictionary[name], sfxVolume, -1); #endif }
public void Play(string name, bool loop) { /* * Sound s = Array.Find(sounds, sound => sound.name == name); * if(s == null) * { * Debug.LogWarning("Sound: " + name + "not found!"); * return; * } * s.source.Play(); */ Sound s = Array.Find(sounds, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + "not found!"); return; } if (loop) { s.stream = AndroidNativeAudio.play(s.id, loop: -1); } else { s.stream = AndroidNativeAudio.play(s.id); } AndroidNativeAudio.setVolume(s.stream, s.volume); s.streamSet = true; }
public void ButtonClicked(string ok) { if (coolDownLeft == 0 && !GameController.Instance.GameOver && !GameController.Instance.AbilityInUse) { if (!GameController.Instance.FXMuted) { if (Application.platform == RuntimePlatform.Android) { streamId = AndroidNativeAudio.play(fileId); } else { GetComponent <AudioSource>().Play(); } } GameController.Instance.AbilityInUse = true; coolDownLeft = Cooldown; isTeleporting = true; GameController.Instance.GodMode = true; baseSpeed = GameController.Instance.GameMovSpeed; teleSpeed = (baseTeleDist * GameController.Instance.DefaultScrollSpeed) / TimeToTeleport; //OnTeleport(); } Debug.Log(ok); }
public void Resume(string name, bool loop) { Sound s = Array.Find(sounds, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + "not found!"); return; } //s.id = AndroidNativeAudio.load(s.name + ".mp3"); if (s.streamSet) { AndroidNativeAudio.resume(s.stream); } else { if (loop) { s.stream = AndroidNativeAudio.play(s.id, loop: -1); s.streamSet = true; } else { s.stream = AndroidNativeAudio.play(s.id); Debug.Log("the stream : " + s.stream); s.streamSet = true; } } }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Rawio") { gameOverSoundID = AndroidNativeAudio.play(gameOverFileID, 0.5f); gameManager.RestartGame(); } }
public void PlaybtnSfx() { #if UNITY_ANDROID && !UNITY_EDITOR playBtnSID = AndroidNativeAudio.play(playBtnFID); #else PlaySingle(btnSfx); #endif }
public void PlaySound(int id, float customRate = 1.0f) { #if UNITY_EDITOR _pcAudio.PlayOneShot((AudioClip)Resources.Load("Sounds/" + _pcAudioReference[id])); #else float level = PlayerPrefs.GetFloat(Constants.PpAudioLevel, Constants.PpAudioLevelDefault); AndroidNativeAudio.play(id, level, rate: customRate); #endif }
void Start() { if (!GameController.Instance.FXMuted) { if (Application.platform == RuntimePlatform.Android) AndroidNativeAudio.play(GameController.Instance.ExplosionWavFileId); else GetComponent<AudioSource>().Play(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Player") { tomatoSoundID = AndroidNativeAudio.play(tomatoFileID, 0.3f); scoreManager.AddScore(scoreToGive); currencyManager.AddCurrency(currencyToGive); gameObject.SetActive(false); } }
public void PlayStuckSound() { if (m_isAndroid) { m_stuckStreamId = AndroidNativeAudio.play(m_stuckSoundId, m_userSettingsManager.UserSettings.SoundEffectVolume); } else { m_stuckSound.PlayOneShot(m_stuckSound.clip, m_userSettingsManager.UserSettings.SoundEffectVolume); } }
public void PlaySuccessfulMenuNavigationSound() { if (m_isAndroid) { m_navigateStreamId = AndroidNativeAudio.play(m_navigateSoundId, m_userSettingsManager.UserSettings.SoundEffectVolume); } else { m_navigateSound.PlayOneShot(m_navigateSound.clip, m_userSettingsManager.UserSettings.SoundEffectVolume); } }
public void PlaySound(int num) { switch (num) { case 0: SoundID = AndroidNativeAudio.play(BopH, PlayerPrefs.GetFloat("SoundsVol", 1f)); break; case 1: SoundID1 = AndroidNativeAudio.play(BopM, PlayerPrefs.GetFloat("SoundsVol", 1f)); break; case 2: SoundID2 = AndroidNativeAudio.play(BopL, PlayerPrefs.GetFloat("SoundsVol", 1f)); break; } }
public void PlaySound(eSound enumS, int loop) { AndroidNativeAudio.setVolume(SoundID[(int)enumS], GameManager.Instance.AudioVolume); SoundID[(int)enumS] = AndroidNativeAudio.play(FileID[(int)enumS], GameManager.Instance.AudioVolume); AndroidNativeAudio.setVolume(SoundID[(int)enumS], GameManager.Instance.AudioVolume); AndroidNativeAudio.setLoop(SoundID[(int)enumS], loop); //for (int i = 0; i < System.Enum.GetValues(typeof(eSound)).Length; i++) //{ // SoundID[i] = AndroidNativeAudio.play(FileID[i]); //} //Debug.Log("GameManager.Instance.AudioVolume" + GameManager.Instance.AudioVolume); }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Player" && !powerUpActive) { powerUpSoundID = AndroidNativeAudio.play(powerUpFileID, 0.2f); gameObject.SetActive(false); //gameObject.GetComponent<Renderer>().enabled = false; player.ChangeMoveSpeed(12); //gameObject.GetComponent<Renderer>().enabled = true; powerUpActive = false; } }
void OnGUI() { GUI.skin.button.fontSize = 32; if (GUI.Button(new Rect(20, 40, 680, 100), "Unity Audio")) { unityAudio.Play(); } if (GUI.Button(new Rect(20, 640, 680, 100), "Native Audio")) { AndroidNativeAudio.play(soundID); } }
public void PlaySFX(string name, float pitch, float volumeFactor = 1) { #if UNITY_EDITOR || UNITY_STANDALONE if (SFXClipDictionary.ContainsKey(name)) { SFXPitch.pitch = pitch; SFXPitch.PlayOneShot(SFXClipDictionary[name], sfxVolume * volumeFactor); } #endif #if !UNITY_EDITOR && UNITY_ANDROID currentSFXStreamID = AndroidNativeAudio.play(SFXFileIDDictionary[name], sfxVolume * volumeFactor, -1, 1, 0, pitch); #endif }