public void SaveMix() // ***saves or adds the audioclip to the "audioClipList" list { // saves or adds the audiosource to the "audioClipList_name" //audioClipList = new List<AudioClip>(); // creates an instance of "audioClipList" list where the audioclips // that are playing are added audioClipList_name = new List <AudioSource>(); audioSources_arr = AudioSource.FindObjectsOfType <AudioSource>(); // finds all GO of type AudioSource and stores // them in an array // Go through all GO and ask if there is an AudioSource component, if there is then // script checks whether its playing, if yes the it will add the clip on the list for (int x = 0; x < audioSources_arr.Length; x++) { if (audioSources_arr[x].isPlaying) { //audioClipList.Add(audioSources_arr[x].clip); audioClipList_name.Add(audioSources_arr[x]); Debug.Log("Added " + audioSources_arr[x].name); //int index = audioClipList.FindIndex(s => s.Equals(audioSources_arr[x])); //Debug.Log(index.ToString()); } } Debug.Log(audioClipList_name.Count); //saveCustomName.ButtonMix(audioSources_arr); }
//Muuttaa kaikkien soivien äänilähteiden soittonopeutta haluttuun. Käytetään äänien pysäyttämiseen kun pausetetaan. void muutaAania(float soittoNopeus) { //varmistetaan että aika kulkee eteenpäin if (soittoNopeus >= 0f) { object[] lista = AudioSource.FindObjectsOfType(typeof(AudioSource)); foreach (AudioSource aani in lista) { //kokeilin pausea ja playtä mutta ne ei jostakin syystä nopeasti toimineet, niin toi toistonopeuden muuttaminen nollaan käy pausesta hyvin aani.pitch = soittoNopeus; } } }
public void SaveMix() { audioClipList = new List <AudioClip>(); allAudioSources = AudioSource.FindObjectsOfType <AudioSource>(); for (int i = 0; i < allAudioSources.Length; i++) { if (allAudioSources[i].isPlaying) { audioClipList.Add(allAudioSources[i].clip); } } }
public void SaveMix() { audioClipList = new List <AudioClip>(); allAudioSources2 = AudioSource.FindObjectsOfType <AudioSource>(); for (int i = 0; i < allAudioSources2.Length; i++) { if (allAudioSources2[i].isPlaying) { audioClipList.Add(allAudioSources2[i].clip); } } foreach (var x in audioClipList) { Debug.Log(x); } }
public void DeleteMix() // stops all audiosources from playing and reverts the buttons to their original sprite { audioSources_arr = AudioSource.FindObjectsOfType <AudioSource>(); allAudioButtons_arr = GameObject.FindGameObjectsWithTag("Audio Button"); // Go through all GO and ask if there is an AudioSource component, if there is then // script checks whether its playing, if yes the it will add the clip on the list for (int x = 0; x < audioSources_arr.Length; x++) { if (audioSources_arr[x].isPlaying) { audioSources_arr[x].Stop(); } } for (int y = 0; y < allAudioButtons_arr.Length; y++) { Button allButtons = allAudioButtons_arr[y].GetComponent <Button>(); allButtons.image.overrideSprite = null; } }
public void StopAllAudio() { btnColor = Image.FindObjectsOfType <Image>(); allAudioSources = AudioSource.FindObjectsOfType <AudioSource>(); for (int j = 0; j < btnColor.Length; j++) { if (btnColor[j].name == "Birds" || btnColor[j].name == "PlaySavedButton" || btnColor[j].name == "Insects" || btnColor[j].name == "Drums" || btnColor[j].name == "Fire" || btnColor[j].name == "Forest" || btnColor[j].name == "Frog" || btnColor[j].name == "Guitar" || btnColor[j].name == "Heartbeat" || btnColor[j].name == "HeavyRain" || btnColor[j].name == "Humming" || btnColor[j].name == "Whale" || btnColor[j].name == "MonkChant" || btnColor[j].name == "Night" || btnColor[j].name == "Notes" || btnColor[j].name == "Orchestra" || btnColor[j].name == "Owl" || btnColor[j].name == "Piano" || btnColor[j].name == "Rain" || btnColor[j].name == "River" || btnColor[j].name == "Snow" || btnColor[j].name == "Sun" || btnColor[j].name == "Thunderstorm" || btnColor[j].name == "Waterfall" || btnColor[j].name == "Ocean") { btnColor[j].color = Color.white; } } for (int i = 0; i < allAudioSources.Length; i++) { if (allAudioSources[i].isPlaying) { allAudioSources[i].Stop(); } } x = GameObject.FindObjectsOfType <GameObject>(); for (int a = 0; a < x.Length; a++) { if (x[a].name == "One shot audio") { Destroy(x[a]); } } SliderX = GameObject.FindGameObjectsWithTag("VolumeSliders"); foreach (var x in SliderX) { x.SetActive(false); } }
public void Process() { //return; if (www != null) { //return; // //return; if (www.isDone) { downloaded = www.bytesDownloaded; AssetBundle bundle = www.assetBundle; //Object[] objs = bundle.LoadAll(); Object[] objs = bundle.LoadAllAssets(); Debug.Log("Asset Bundle Objects count = " + objs.Length); foreach (Object o in objs) { Debug.Log("Object " + o.name + " type:" + o.GetType()); } if (bundle.mainAsset == null) { go = new GameObject("object_root"); go.transform.position = position; go.transform.eulerAngles = angles; foreach (Object o in objs) { if (o != null) { GameObject goChild = GameObject.Instantiate(o) as GameObject; if (goChild != null) { goChild.name = o.name; goChild.transform.parent = go.transform; } } } //Debug.LogError ("ERROR : " + www.url); //www.Dispose(); //www = null; //return; } else { go = GameObject.Instantiate(www.assetBundle.mainAsset) as GameObject; go.name = www.assetBundle.mainAsset.name; go.transform.position = position; go.transform.eulerAngles = angles; } www.assetBundle.Unload(false); www.Dispose(); www = null; AudioSource[] sources = AudioSource.FindObjectsOfType(typeof(AudioSource)) as AudioSource[]; //audio sources have to be augmented with specific NA behaviour Debug.Log("Sources count = " + sources.Length); foreach (AudioSource s in sources) { NA.DecorateAudioSource(s); s.rolloffMode = AudioRolloffMode.Linear; } AudioListener al = go.GetComponent <AudioListener> (); if (al != null) { al.enabled = false; } /* * NAReverbResonator[] resonators = NAReverbResonator.FindObjectsOfType(typeof(NAReverbResonator)) as NAReverbResonator[]; * * Debug.Log ("NAReverbResonator count = " + resonators.Length); * foreach (NAReverbResonator r in resonators) * { * NAReverbEffector eff = r.gameObject.GetComponent<NAReverbEffector>(); * if (eff == null) * r.gameObject.AddComponent<NAReverbEffector>(); * AudioReverbFilter arf = r.gameObject.GetComponent<AudioReverbFilter>(); * if (arf == null) * r.gameObject.AddComponent<AudioReverbFilter>(); * } */ } } }