jackm36 / eazy-sound-manager Goto Github PK
View Code? Open in Web Editor NEWEazy Sound Manager is a simple Unity3D tool which aims to make sound and music management in games easier
License: MIT License
Eazy Sound Manager is a simple Unity3D tool which aims to make sound and music management in games easier
License: MIT License
UnityException: FindObjectsOfType is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'EazySoundManager' on game object 'GameManager'.
Line 68 in EazySoundManager script
instance = (EazySoundManager)FindObjectOfType(typeof(EazySoundManager));
Hi, i'm searching an asset to play an audio live stream from my icecast server
do this asset / lib do this ?
Thanks for answering
All audiosources are added as components to the EasySoundManager gameObject. So how are audiosources at various locations supposed to work when there is only one EasySoundManager position?
And secondly: the position of EasySoundManager doesn't seem to be set to the sourceTransform.position. The 3D support seems untested.
Hi! After reading the message about the memory leak, I downloaded the version from the github. And that's what the profiler showed...
Only one source of music plays, nothing more, but the garbage collector does not calm down ... :) (Assetstore version -the same picture)
PS Sorry for googletranslate :)
When audio's id that is created in Start() is used with EazySoundManager.GetMusicAudio(id).Play() in Start(), the sound plays.
But the id is used in Update(), the sound does'nt play.
Stop() is work in Update().
Why?
I wrote the following code.
`
public class MusicManager : MonoBehaviour {
public AudioClip wbgm;
private Dictionary<string,int> ids = new Dictionary<string,int>();
void Start(){
ids["wbgm"] = EazySoundManager.PrepareMusic(wbgm, 1.0f, true,false);
//this.Play("wbgm");
}
void Update(){
if(Input.GetKeyDown(KeyCode.Space)){
//ids["wbgm"] = EazySoundManager.PrepareMusic(wbgm, 1.0f, true,false);
this.Play("wbgm");
}
}
public void Play(string name){
EazySoundManager.GetMusicAudio(ids[name]).Play();
}
}
I'd like to request a playlist queue feature for Eazy Sound Manager.
The idea would be that I can queue up several sounds in a row to play in sequence. My particular use case for this would be to queue up 3-4 songs as background music, and have ESM cycle through them automatically. This would save me from writing my own code to monitor the playing status of ESM and starting the next song manually.
Suggested things:
SoundManager.AddToQueue(clip)
SoundManager.RemoveFromQueue(clip)
AudioClip[] SoundManager.CurrentQueue()
SoundManager.queueLength
SoundManager.PlayQueue()
SoundManager.QueueParams(fadeInTime, fadeOutTime, loop, persist)
Alternatively, if you'll give me some guidance on how you'd like it done I'll take a look and implementing it in a pull request.
Thanks!
Hello Jack,
Thanks for an awesome asset. Would it be possible to add support for our audiomixers so global volume can be drawn from there?
Regards
I had solve this problem, you forget to delete the unnecessary "add component()" in playsound function, there are two audiosource was generated when playsound.
Hi!
Thanks for this great tool! It is exactly what I was looking for! But I ran into a bunch of problems when setting the ignoreDuplicateMusic property to true.
When setting SoundManager.ignoreDuplicateMusic = true;
in a custom script I use for audio management (I tried placing it in Start,Awake,OnEnable
), and playing music by SoundManager.PlayMusic(...)
, I get following exception:
NullReferenceException: Object reference not set to an instance of an object EazyTools.SoundManager.SoundManager.PlayMusic (UnityEngine.AudioClip clip, System.Single volume, System.Boolean loop, System.Boolean persist, System.Single fadeInSeconds, System.Single fadeOutSeconds, System.Single currentMusicfadeOutSeconds, UnityEngine.Transform sourceTransform) (at Assets/Eazy Tools/Sound Manager/Scripts/SoundManager.cs:478) EazyTools.SoundManager.SoundManager.PlayMusic (UnityEngine.AudioClip clip, System.Single volume, System.Boolean loop, System.Boolean persist) (at Assets/Eazy Tools/Sound Manager/Scripts/SoundManager.cs:439)
I looked at the code - this happens because the static field musicAudio
is accessed before calling Init()
.
I did not add the script to the scene (as being written in your installation instructions), therefore the Awake
function (which calls Init()
) is not called. For now, i fixed(?) this by accessing the SoundManager instance (and therefore triggering Init()) with this:
var unusedGO = SoundManager.gameobject;
SoundManager.ignoreDuplicateMusic = true; //Has to be set after, as it get's overriden by Init()
When using the fix described above and trying to play an AudioClip with SoundManager.PlayMusic(clip)
that I already played before, I get this exception:
MissingReferenceException: The object of type 'AudioSource' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. EazyTools.SoundManager.SoundManager.PlayMusic (UnityEngine.AudioClip clip, System.Single volume, System.Boolean loop, System.Boolean persist, System.Single fadeInSeconds, System.Single fadeOutSeconds, System.Single currentMusicfadeOutSeconds, UnityEngine.Transform sourceTransform) (at Assets/Eazy Tools/Sound Manager/Scripts/SoundManager.cs:481) EazyTools.SoundManager.SoundManager.PlayMusic (UnityEngine.AudioClip clip, System.Single volume, System.Boolean loop, System.Boolean persist) (at Assets/Eazy Tools/Sound Manager/Scripts/SoundManager.cs:439)
I keep the AudioClip in a Dictionary on my script and do not call any functions on it. I only get it from the Dict and pass it to the SoundManager. This works perfectly fine when not setting ignoreDuplicateMusic!
In this case i just keep track of the current track myself. :)
I found that when finish play sound , the audio clip didn't release, when I check unity profiler , it referenced by ManagedStaticReferentces( ).
When playing sound you set starting volume to 0 and on Update() change it. But when a sound is short(20 ms), it can be played on 0 volume before the first Update() tick occurs.
When I use PlayMusic() and leave the application the music stops.
This Asset would be PERFECT if it wern't for this one bug.
Please fix. - J
I use these methods when pause the game, but I don't have control of variable audioSource. To solve this, I add a verification on Pause, UnPause and Resume. An example on line 979:
if (audioSource)
{
audioSource.Pause();
paused = true;
}
When EazySoundManager.PrepareMusic is used, Error happen with SceneManager.LoadScene().
Log:
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary2[System.Int32,Hellmade.Sound.Audio].get_Item (Int32 key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:561) Hellmade.Sound.EazySoundManager.RemoveNonPersistAudio (System.Collections.Generic.Dictionary
2 audioDict) (at Assets/Support/Eazy-Sound-Manager-master/Assets/Hellmade/Eazy Sound Manager/Scripts/EazySoundManager.cs:232)
Hellmade.Sound.EazySoundManager.OnSceneLoaded (Scene scene, LoadSceneMode mode) (at Assets/Support/Eazy-Sound-Manager-master/Assets/Hellmade/Eazy Sound Manager/Scripts/EazySoundManager.cs:128)
UnityEngine.SceneManagement.SceneManager.Internal_SceneLoaded (Scene scene, LoadSceneMode mode) (at C:/buildslave/unity/build/Runtime/Export/SceneManager/SceneManager.cs:122)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.