Enabling/Disabling Plugins at Runtime

How to ensure your plugin cleanly unloads and reloads itself within Visionary Render

Plugins can be loaded and unloaded dynamically, by using the Plugins interface in the Settings window. All plugins, if they start unloaded, can be loaded at any time via this interface, regardless of whether any special considerations are made within the plugin.

When attempting to unload plugins, those that do not implement their own cleanup procedures will not unload until the next application restart, in which case they will not be loaded automatically when the application starts up. The plugin manager interface will display a "Restart Required" message if the user attempts to unload a plugin without a cleanup function.

In order to make a plugin support unloading, it must implement VRPCleanup.

PLUGIN_ENTRY_POINT int VRTREE_APIENTRY VRPCleanup()
{
  //clean things
  return 0;
}
local function cleanup()
  -- clean things
end

return {
  -- alongside existing exports
  cleanup = cleanup
}
The presence of this function lets the plugin loader know that the plugin can be unloaded dynamically, so it is important that the implementation correctly cleans up its resources and hooks.

Examples of things that should be cleaned up include:

  • Callback functions such as those given to VRRegisterEventFunction, or any other callback registration mechanism should be unregistered

  • Menus created / injected into application menus should be removed and deleted

  • Any internal allocations made by the plugin should be deleted - simply unloading the plugin does not automatically free any memory it allocated

However, it may be necessary to ensure that a plugin cannot be enabled/disabled during runtime.

Plugins that should not be enabled/disabled during run time should implement their own locked function, returning "true" if the state of the plugin is not be changed during runtime.

PLUGIN_ENTRY_POINT bool VRTREE_APIENTRY VRPLocked()
{
  return true;
}
local function locked()
  return true
end

return {
  -- alongside existing exports
  locked = locked
}


No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtree_cppCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API