No announcement yet.

Creating Plugin with Optional Dependencies

  • Filter
  • Time
  • Show
Clear All
new posts

    Creating Plugin with Optional Dependencies

    Initial Question:
    Is there a method to produce a plugin which compiles correctly in an empty project but can also contain additional logic which is compiled and activated when built in a project with another plugin enabled?

    Use Case:
    My plugin should have behaviour that only applies if it's being used in a project built for the SteamVR plugin, and have different behaviour that applies if it's being used in a project built for the "Oculus VR" plugin. My plugin's C++ code must be able to call functions that are declared/defined in the SteamVR/Oculus VR plugins.

    A few ideas:
    Plugin Descriptor File - I'm aware that you can flag an entire plugin as having a required dependency on another plugin, but what we're looking for is more an ability to flag a specific module inside that plugin as depending on another plugin, and if that dependency isn't found, skip that module.
    Precompile Defines - This is likely a required part of the solution to enable some plugin-specific code to become inactive when its dependency isn't found. Not sure where to start with manipulating these though.
    Reflection - Should work for this type of thing but not sure of the intricacies with Unreal's build process. Also a bummer due to the lack of compile-time safety and potential performance hit(?).

    Let me know if you've run into this problem before and how you went about solving it.


    We have an open feature request for being able to check whether plugins are enabled from .build.cs files. It's a little tricky though; we don't want to allow you to modify build settings in response to it, because that would break the installed engine build and plugin marketplace, where everything is already precompiled. So it would probably have to be a separate module that's conditionally enabled and dynamically loaded at runtime via settings in the plugin file.