I have registered a callback to get errors that looks like this and I am trying to get the name of the callbackInfo.instance to debug it but callbackInfo.instancetype is a ERRORCALLBACK_INSTANCETYPE.CHANNELCONTROL and reading the docs it corresponds to an IChannelControl interface which can be either a Channel or a ChannelGroup and I cant figure out a way to determine which one it actually is and if I chose wrong all I get is garbage.
var errorCallback = new FMOD.SYSTEM_CALLBACK(ERROR_CALLBACK);
system.setCallback(errorCallback, FMOD.SYSTEM_CALLBACK_TYPE.ERROR);
private static FMOD.RESULT ERROR_CALLBACK(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata)
{
FMOD.ERRORCALLBACK_INFO callbackInfo = Marshal.PtrToStructure<FMOD.ERRORCALLBACK_INFO>(commanddata1);
if(callbackInfo.instancetype == ERRORCALLBACK_INSTANCETYPE.CHANNELGROUP)
{
// get the name or other identifier of the callbackInfo.instance
}
}
So I either need a way to determine which type it is or a way to get the name without knowing the type.
Edit 1: To clarify, both Channel and ChannelGroup have constructors that take an IntPtr, thats the only way i have found to actually create those objects. Marshalling like is done above for the ERRORCALLBACK_INFO does not work since the structs dont have any actual data and is just a wrapper for a c++ object.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744714353a4589528.html
评论列表(0条)