|
Post by Niocron on Feb 4, 2023 16:24:37 GMT
Hello,
i just started to migrate to your audio asset and wonder if there is another possibility to avoid magic strings than to use the [SoundGroupAttribute]. Like a class with static string variables that reflect the exisiting sound groups. I only found the full list of groups but in order to get a specific sounds group string i would need to select from the list and therefore again have to use a magic string.
Thanks and regards, Niocron
|
|
|
Post by DarkTonic Dev on Feb 5, 2023 1:07:44 GMT
I'm a programmer at my day job as well, and what I refer to as magic strings are non-constants. Allowing you to select from a white-list of choices makes that not magic strings to me, IMO.
Originally Master Audio had you add a line of code to an Enum for each new Sound Group but everyone complained about that (understandably) so we eliminated that.
Anyway, you can use whatever you like if you don't like the attribute, but that's how the Property Drawer works. You could create a different one I suppose.
|
|
|
Post by Niocron on Feb 5, 2023 10:58:54 GMT
Yeah the attribute eleminates the magic string and works pretty well in most cases. I was refering to if i want to get the string in runtime via MasterAudio.RuntimeSoundGroupNames i would have to use a magic string to compare to the entries of the list to get the correct one. Nevermind i just created my own static string class but you could think about creating that class automatically via reflection if the user adds a new soundgroup. It would help for classes that do not inherit from mononhaviours.
Thanks for your reply
|
|
|
Post by DarkTonic Dev on Feb 5, 2023 17:39:42 GMT
Sorry, I'm not understanding your use case. I don't know why one would compare what you're comparing. You can email us a complete breakdown and I'll reply, if you like.
Glad you are unblocked.
|
|