eomono
New Member
Posts: 11
Posts: 11
|
Post by eomono on Apr 16, 2020 7:16:19 GMT
Hello!
Is there a difference between MasterAudio.PlaySound() and setting up a proper Custom Event and firing it up? I'm asking because MasterAudio.PlaySound() seems more convenient to use but wouldn't want to overuse it if there is some kind of disadvantage in relation to custom events.
Also, I had the idea that string search was very bad performance-wise, even to the extent that we use the StringToHash function to avoid its usage when handling animations. Is there an alternative to name strings when firing events or playing sounds?
Thank you!
|
|
|
Post by DarkTonic Dev on Apr 16, 2020 19:31:30 GMT
Not sure what string search you are referring to, but everything in Master Audio is stored in dictionaries - yes it has a string key, but it's very fast since it's a dictionary. You should not see any lookup penalties. And I don't know of any alternatives.
MasterAudio.PlaySound is if you want to do a single thing. Make sure to use the "AndForget" methods if you don't need the handle to stop the sound later, such as MasterAudio.PlaySound3DFollowTransformAndForget.
Where Custom Events are used a lot is when you have complex things you want to do with a bunch of audio events. An audio designer may set up an Event Sounds script in the scene with whatever he wants to happen, and can test fire the Custom Event using the Master Audio Inspectors. If any custom logic is needed to fire the event, the designer can request that the programmers add the 1-liners MasterAudio.FireCustomEvent, etc. into the code.
It's also great for when you want whatever Custom Event listeners are in a certain distance of an event to "react". The performance of both methods is pretty good.
|
|
eomono
New Member
Posts: 11
Posts: 11
|
Post by eomono on Apr 20, 2020 11:27:45 GMT
I see! Thank you so much for your reply!
|
|
|
Post by DarkTonic Dev on Apr 20, 2020 15:06:23 GMT
Any time.
|
|