This PR aims to simplify the usage of Wwise callbacks in Godot. It removes the signal processing for callbacks from the C++ codebase and implements FuncRefs as callbacks cookies.
With FuncRefs we can create a reference to a function in a given object and pass the reference around, i.e. in this implementation as a cookie to the respective Wwise callbacks. We then can call the referenced function directly from the Wwise callbacks, bypassing the signal processing in _process().
post_event_callback, post_event_id_callback, load_bank_async, load_bank_async_id, unload_bank_async and unload_bank_async_id now require an Object argument, which should be a FuncRef created in GDScript.
Event callback example:
export(AK.EVENTS._enum) var event = AK.EVENTS.MUSIC
export(AkUtils.AkCallbackType) var callback_type = AkUtils.AkCallbackType.AK_MusicSyncBeat
var cookie:FuncRef
func _ready():
var registerResult = Wwise.register_game_obj(self, "Beat Callback Test")
print("Registering GameObject: ", registerResult)
cookie = FuncRef.new() # needs to be an instance variable
cookie.set_instance(self) # instance in which the function should be called
cookie.set_function("beat_callback") # name of the function
Wwise.post_event_id_callback(event, callback_type, self, cookie)
func beat_callback(data):
print(data)
This PR aims to simplify the usage of Wwise callbacks in Godot. It removes the signal processing for callbacks from the C++ codebase and implements FuncRefs as callbacks cookies.
With FuncRefs we can create a reference to a function in a given object and pass the reference around, i.e. in this implementation as a cookie to the respective Wwise callbacks. We then can call the referenced function directly from the Wwise callbacks, bypassing the signal processing in
_process()
.post_event_callback
,post_event_id_callback
,load_bank_async
,load_bank_async_id
,unload_bank_async
andunload_bank_async_id
now require anObject
argument, which should be aFuncRef
created in GDScript.Event callback example:
Bank callback example:
The
AkEvent
node was modified to allow this new implementation to work with the existing signals present in the custom node.