Search Unity

How to load native plugin before graphics device initialization

Discussion in 'Scripting' started by ProgramUrFace, Jun 9, 2019.

  1. ProgramUrFace

    ProgramUrFace

    Joined:
    Sep 10, 2013
    Posts:
    10
    I am writing a native plugin aimed at Vulkan and needed to configure the instance creation, to do that I need to call "InterceptInitialization" on the unity Vulkan interface before the device is created, however I can not seem to get my plugin to load before the device is created.

    Inside the header file which contains the "InterceptInitialization" method I see that it says:
    // Must be called before kUnityGfxDeviceEventInitialize (preload plugin)
    So I looked into plugin preloading and tried a few things:
    • I checked the "Load on startup" checkbox in the plugin inspector, when I go into "Debug" view in the inspector it shows that the plugin's "Is Preloaded" variable is set to true. I restarted unity and ran the code and it did not work.
    • I added the prefix "GfxPlugin" before the DLL; restarted the editor. This still did nothing.
    What is the proper way to load a plugin before the Graphics Device is initialized?
     
  2. heeen

    heeen

    Joined:
    Oct 21, 2016
    Posts:
    6
    I would like to comment that this used to work in 2018 and on 2019 I am facing the same issue.
     
  3. ProgramUrFace

    ProgramUrFace

    Joined:
    Sep 10, 2013
    Posts:
    10
    I somehow got it working, I think you have to restart unity more than once to see the effects. All that you need to do is add the prefix GfxPlugin to your DLL and restart Unity a bunch of times. Another thing to consider is the unity version. Right now I am using Unity 2019.1, I was using the newest alpha 2019.3 and that could have been part of the issue, I can't say for sure.
     
  4. steven_jackson_innopeaktech

    steven_jackson_innopeaktech

    Joined:
    Aug 12, 2022
    Posts:
    2
    Is this still a valid solution?

    I find that when running a build on Linux it doesn't recognize the GfxPlugin prefix, and instead cannot find the plugin because of the prefix.