void Start()
 {
     audioData.GetComponents <AudioSource>();
     audioData2.GetComponents <AudioSource>();
     audioData.Play(0);
     audioData2.Play(0);
 }
Example #2
0
    // Use this for initialization
    void Start()
    {
        Twine = new TwineImporter1();
//		GUI.skin = GameGui;
        mousePos = new Vector3(8, -4, -9);
        mouse.transform.position = mousePos;
        mouse.enabled            = false;
        remy.enabled             = false;
        comcast.enabled          = false;
        judge.enabled            = false;
        explosion.enabled        = false;
        remySources    = remyAudio.GetComponents <AudioSource>();
        judgeSources   = judgeAudio.GetComponents <AudioSource>();
        comcastSources = comcastAudio.GetComponents <AudioSource>();


//		remyClips[0] = AudioClip.Create("R_eh-eh.mp3", 44100, 1, 44100, false, true);
//		remyClips[1] = AudioClip.Create("R_Hmmmm.mp3", 44100, 1, 44100, false, true);
//		remyClips[2] = AudioClip.Create("R_Mhma.mp3", 44100, 1, 44100, false, true);
        //remyClips[3] = "R_mmhm.mp3";
        //remyClips[4] = "R_MMM.mp3";
        //remyClips[5] = "R_pssh.mp3";
        // string toDisplay = "Whatever data is being sent, be it cat pictures, live video, " +
        // "or life-saving tools about water filtration, all this data is subjected" +
        //  "to Internet Service Providers whims without Net Neutrality. Net Neutrality" +
        //      "keeps Internet Service Provider fair and balanced about their data transfer. " +
        //      "Without Net Neutrality, cat pictures online could be eradicated. ";

        TypeText();
    }
        /// <summary>
        /// Returns the attached AudioSourceCallback, creates one and attaches it if there is none.
        /// </summary>
        /// <param name="source">this</param>
        /// <returns><see cref="AudioSourceCallback"/></returns>
        public static AudioSourceCallback GetCallback(this AudioSource source)
        {
            var callback = source.GetComponents <AudioSourceCallback>()
                           .FirstOrDefault(cb => cb.Source == source);

            if (callback == null)
            {
                callback        = source.gameObject.AddComponent <AudioSourceCallback>();
                callback.Source = source;
            }

            return(callback);
        }
Example #4
0
 bool HasOtherComponents(GameObject go)
 {
     Component[] components = source.GetComponents <Component>();
     foreach (Component component in components)
     {
         if (component is Transform)
         {
             continue;
         }
         if (component is AudioSource)
         {
             continue;
         }
         return(true);
     }
     return(false);
 }
Example #5
0
 public static void PlayClipObjectAndDestroy(AudioSource audioSource)
 {
     if (audioSource != null)
     {
         GameObject oneShotObject = new GameObject("One shot sound from " + audioSource.name);
         audioSource.transform.SetParent(oneShotObject.transform);
         foreach (var audio in audioSource.GetComponents <AudioSource>())
         {
             audio.Stop();
         }
         audioSource.Play();
         MonoBehaviour.Destroy(oneShotObject, audioSource.clip.length + 1f);
     }
     else
     {
         //  Debug.Log("Cannot play an audio source that has been destroyed");
     }
 }
//		public static Changer ChangeOpacity(this GameObject gameObject, float startOpacity, float finalOpacity, float time)
//		{
//			OpacityChanger changer = gameObject.GetComponent<OpacityChanger>();
//			if (changer == null)
//				changer = gameObject.AddComponent<OpacityChanger>();
//
//			changer.startValue = startOpacity;
//			changer.finalValue = finalOpacity;
//			changer.requiredTime = time;
//
//			changer.Launch();
//
//			return changer;
//		}
//
        public static Changer ChangeVolume(this AudioSource audioSource, float startVolume, float finalVolume, float time)
        {
            AudioSourceVolumeChanger changer = Array.Find(audioSource.GetComponents <AudioSourceVolumeChanger>(), x => x.audioSource == audioSource);

            if (changer == null)
            {
                changer             = audioSource.gameObject.AddComponent <AudioSourceVolumeChanger>();
                changer.audioSource = audioSource;
            }

            audioSource.volume   = startVolume;
            changer.startValue   = startVolume;
            changer.finalValue   = finalVolume;
            changer.requiredTime = time;

            changer.Launch();

            return(changer);
        }
Example #7
0
        protected void Awake()
        {
            instance = this;

            soundsSources    = new List <AudioSource>(_soundsSources.GetComponents <AudioSource>());
            musicSources     = _musicSources.GetComponents <AudioSource>();
            soundSourceIndex = 0;
            DebugUtils.Log(string.Format("Using {0} sound sources and {1} music sources", soundsSources.Count, musicSources.Length));

            foreach (var musicSource in musicSources)
            {
                musicSource.ignoreListenerVolume = true;
                musicSource.loop = true;
            }
            foreach (var soundsSource in soundsSources)
            {
                soundsSource.loop = false;
            }

            SetMusicVolume(1);
            SetMasterSoundVolume(masterSoundVolume);
        }
 static public void start()
 {
     if (!StartGame)
     {
         StartGame = true;
         GenerateGameobjsOnAStreet(streetOne, true);
         GenerateGameobjsOnAStreet(streetTwo, false);
         if (!muted)
         {
             AudioSource gametrack = mainTracks.GetComponents <AudioSource> () [0];
             gametrack.loop = true;
             AudioSource slowtrack = mainTracks.GetComponents <AudioSource> () [1];
             slowtrack.Stop();
             gametrack.Play();
         }
         titlescreen.SetActive(false);
         scorescreen.SetActive(true);
         gamecontrolscreen.SetActive(true);
     }
 }
Example #9
0
 /*
  * Returns a random AudioSource if the game object that holds
  * audioSource has more than one AudioSource component.
  */
 private AudioSource GetRandomAudio(AudioSource audioSource)
 {
     AudioSource[] sources = audioSource.GetComponents <AudioSource>();
     return(sources[Random.Range(0, sources.Length)]);
 }
 // Start is called before the first frame update
 void Start()
 {
     audioSource.GetComponents <AudioSource>();
     //audioSource.PlayOneShot(heartBeat_Whole, 1);
     timePassed = 0.5f;
 }