But I SHOULD be able to fix some performance issues with the sound system by using UnityEngine's Object.GetInstanceId(), which returns a guaranteed unique id for every object. I can concat the unique gameObject id with the name of the soundEffect that has been paired with it and use that as the key when I want to lookup that specific soundEffect instance again.
Which in turn means I can eliminate the Transform.FindChild() call I am making in startLooping and stopLooping.
Which, gentle readers, should make it run faster since I am not searching a gameObject hierarchy every time a sound system method is called.
That said, you should still only be calling startLooping or stopLooping once on a state change, not every frame the object is in a state that needs a sound effect.
/spam
No comments:
Post a Comment