Created
June 22, 2015 05:55
-
-
Save reidblomquist/c22687bf22238d46447a to your computer and use it in GitHub Desktop.
Loader and SoundManager scripts referenced in TextTyper class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Loader : MonoBehaviour { | |
public GameObject gameManager; | |
public GameObject soundManager; | |
void Awake () { | |
if (gameManager && GameManager.instance == null) | |
Instantiate(gameManager); | |
if (soundManager && SoundManager.instance == null) | |
Instantiate(soundManager); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SoundManager : MonoBehaviour { | |
public AudioSource efxSource; | |
public AudioSource musicSource; | |
public static SoundManager instance = null; | |
public float lowPitchRange = 0.95f; | |
public float highPitchRange = 1.05f; | |
void Awake () { | |
if (instance == null) | |
instance = this; | |
else if (instance != this) | |
Destroy (gameObject); | |
DontDestroyOnLoad (gameObject); | |
} | |
public void PlaySingle (AudioClip clip) { | |
efxSource.clip = clip; | |
efxSource.Play(); | |
} | |
public void RandomizeSfx (params AudioClip [] clips) { | |
int randomIndex = Random.Range(0, clips.Length); | |
float randomPitch = Random.Range (lowPitchRange, highPitchRange); | |
efxSource.pitch = randomPitch; | |
efxSource.clip = clips[randomIndex]; | |
efxSource.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment