{"action":"created","issue":{"url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/7","repository_url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager","labels_url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/7/comments","events_url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/7/events","html_url":"https://github.com/JackM36/Eazy-Sound-Manager/issues/7","id":280652252,"node_id":"MDU6SXNzdWUyODA2NTIyNTI=","number":7,"title":"Exceptions when setting ignoreDuplicateMusic = true","user":{"login":"Kruemelkatze","id":5564731,"node_id":"MDQ6VXNlcjU1NjQ3MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5564731?v=4","gravatar_id":"","url":"https://api.github.com/users/Kruemelkatze","html_url":"https://github.com/Kruemelkatze","followers_url":"https://api.github.com/users/Kruemelkatze/followers","following_url":"https://api.github.com/users/Kruemelkatze/following{/other_user}","gists_url":"https://api.github.com/users/Kruemelkatze/gists{/gist_id}","starred_url":"https://api.github.com/users/Kruemelkatze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kruemelkatze/subscriptions","organizations_url":"https://api.github.com/users/Kruemelkatze/orgs","repos_url":"https://api.github.com/users/Kruemelkatze/repos","events_url":"https://api.github.com/users/Kruemelkatze/events{/privacy}","received_events_url":"https://api.github.com/users/Kruemelkatze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-09T00:00:05Z","updated_at":"2018-08-18T20:02:25Z","closed_at":null,"author_association":"NONE","body":"Hi!\r\nThanks 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.\r\n\r\n### 1) NullReferenceException when setting it to true before first usage\r\nWhen 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:\r\n\r\n`NullReferenceException: Object reference not set to an instance of an object\r\nEazyTools.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)\r\nEazyTools.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)`\r\n\r\nI looked at the code - this happens because the static field `musicAudio` is accessed before calling `Init()`.\r\n\r\nI 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:\r\n\r\n ```cs\r\nvar unusedGO = SoundManager.gameobject;\r\nSoundManager.ignoreDuplicateMusic = true; //Has to be set after, as it get's overriden by Init()\r\n```\r\n\r\n### 2) MissingReferenceException when trying to play music that has been played before\r\nWhen using the fix described above and trying to play an AudioClip with `SoundManager.PlayMusic(clip)` that I already played before, I get this exception:\r\n`MissingReferenceException: The object of type 'AudioSource' has been destroyed but you are still trying to access it.\r\nYour script should either check if it is null or you should not destroy the object.\r\nEazyTools.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)\r\nEazyTools.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)`\r\n\r\nI 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!\r\n\r\n### Is ignoreDuplicateMusic even supposed to be used?\r\nIn this case i just keep track of the current track myself. :)"},"comment":{"url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/comments/414082998","html_url":"https://github.com/JackM36/Eazy-Sound-Manager/issues/7#issuecomment-414082998","issue_url":"https://api.github.com/repos/JackM36/Eazy-Sound-Manager/issues/7","id":414082998,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDA4Mjk5OA==","user":{"login":"Kruemelkatze","id":5564731,"node_id":"MDQ6VXNlcjU1NjQ3MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5564731?v=4","gravatar_id":"","url":"https://api.github.com/users/Kruemelkatze","html_url":"https://github.com/Kruemelkatze","followers_url":"https://api.github.com/users/Kruemelkatze/followers","following_url":"https://api.github.com/users/Kruemelkatze/following{/other_user}","gists_url":"https://api.github.com/users/Kruemelkatze/gists{/gist_id}","starred_url":"https://api.github.com/users/Kruemelkatze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kruemelkatze/subscriptions","organizations_url":"https://api.github.com/users/Kruemelkatze/orgs","repos_url":"https://api.github.com/users/Kruemelkatze/repos","events_url":"https://api.github.com/users/Kruemelkatze/events{/privacy}","received_events_url":"https://api.github.com/users/Kruemelkatze/received_events","type":"User","site_admin":false},"created_at":"2018-08-18T20:02:25Z","updated_at":"2018-08-18T20:02:25Z","author_association":"NONE","body":"Is there any update on these issues? Or did I miss anything? :)"}}
{"actor":{"display_login":"Kruemelkatze"}}