|
Post by Illusion Walk on Nov 3, 2020 17:21:14 GMT
Hello,
with version 2020.3.4 of MasterAudio I get a Key Not Found Exception when playing a variant.
This happens because the MasterAudio._nonRandomChoise dictionary is always empty (at least in my case). The dictionary initialization in Awake is too early because the SoundGroups aren't created at this time.
So that is why there will be a KeyNotFoundException at line 2486 in MasterAudio.cs when I am trying to play an audio variant.
As a workaround I have changed the line 2486 from
var choiceMatches = Instance._nonRandomChoices[sType] to
if (!Instance._nonRandomChoices.TryGetValue(sType, out var choiceMatches)) { choiceMatches = new List<int>(); }
Is it a bug or I doing something wrong?
Thanks for help.
|
|
|
Post by DarkTonic Dev on Nov 5, 2020 0:25:14 GMT
We should fix the problem at its source, not there. If you say the Sound Groups don't exist yet at Awake, are you talking about Sound Groups created by Dynamic Sound Group Creator game objects? If so, I may be missing a line to add to _nonRandomChoices inside CreateSoundGroup method, called by DSGC.
Please let me know if I am correct, and I will make the change.
-Brian
|
|
|
Post by Illusion Walk on Nov 5, 2020 8:27:19 GMT
Exactly.
I am using Sound Groups created by Dynamic Sound Group Creator.
And yes, my code change was just a hacky workaround and it would be great to have a real fix for this problem.
|
|
|
Post by DarkTonic Dev on Nov 5, 2020 21:10:17 GMT
Ok add this line in MasterAudio.cs just before RescanGroupsNow(), line 4731.
Instance._nonRandomChoices.Add(groupName, new List<int>());
The next update will have this fix.
|
|
|
Post by Illusion Walk on Nov 6, 2020 8:23:44 GMT
Thank you very much!
|
|
|
Post by DarkTonic Dev on Nov 6, 2020 16:36:20 GMT
No problem.
|
|