pluginCallbacks.cpp
#include <maya/MIOStream.h>
#include <maya/MPxNode.h>
#include <maya/MFnPlugin.h>
#include <maya/MSceneMessage.h>
void prePluginLoadCallback( const MStringArray &str, void* cd )
{
cerr << "PRE plugin load callback with " << str.length() << " items: \n";
for (unsigned int i = 0; i < str.length(); i++ )
{
cerr << "\tCallback item " << i << " is : " << str[i] << endl;
}
}
void postPluginLoadCallback( const MStringArray &str, void* cd )
{
cerr << "POST plugin load callback with " << str.length() << " items: \n";
for (unsigned int i = 0; i < str.length(); i++ )
{
cerr << "\tCallback item " << i << " is : " << str[i] << endl;
}
}
void prePluginUnloadCallback( const MStringArray &str, void* cd )
{
cerr << "PRE plugin unload callback with " << str.length() << " items: \n";
for (unsigned int i = 0; i < str.length(); i++ )
{
cerr << "\tCallback item " << i << " is : " << str[i] << endl;
}
}
void postPluginUnloadCallback( const MStringArray &str, void* cd )
{
cerr << "POST plugin unload callback with " << str.length() << " items: \n";
for (unsigned int i = 0; i < str.length(); i++ )
{
cerr << "\tCallback item " << i << " is : " << str[i] << endl;
}
}
static MCallbackId prePluginLoadCallbackId;
static MCallbackId postPluginLoadCallbackId;
static MCallbackId prePluginUnloadCallbackId;
static MCallbackId postPluginUnloadCallbackId;
MStatus initializePlugin( MObject obj )
{
MStatus status;
prePluginLoadCallbackId = MSceneMessage::addCallback(MSceneMessage::kBeforePluginLoad,
prePluginLoadCallback,
NULL, &status);
postPluginLoadCallbackId = MSceneMessage::addCallback(MSceneMessage::kAfterPluginLoad,
postPluginLoadCallback,
NULL, &status);
prePluginUnloadCallbackId = MSceneMessage::addCallback(MSceneMessage::kBeforePluginUnload,
prePluginUnloadCallback,
NULL, &status);
postPluginUnloadCallbackId = MSceneMessage::addCallback(MSceneMessage::kAfterPluginUnload,
postPluginUnloadCallback,
NULL, &status);
return MS::kSuccess;
}
MStatus uninitializePlugin( MObject obj)
{
MSceneMessage::removeCallback( prePluginLoadCallbackId );
MSceneMessage::removeCallback( postPluginLoadCallbackId );
MSceneMessage::removeCallback( prePluginUnloadCallbackId );
MSceneMessage::removeCallback( postPluginUnloadCallbackId );
return MS::kSuccess;
}