Search Unity

Run code before the Direct3D device is initialized

Discussion in 'Windows' started by georgehornmoen_hinterland, Jan 5, 2021.

  1. georgehornmoen_hinterland

    georgehornmoen_hinterland

    Joined:
    Nov 12, 2020
    Posts:
    2
    Hi all,

    I am integrating an external SDK that requires a call to be made before Unity initializes the Direct3D device so that it can render an overlay in the game (triggered by a key-combo).

    The SDK is a native 64-bit DLL with a C# wrapper for most of the functionality.

    Our final build is compiled using IL2CPP and on Unity 2019.4.x

    I need this for Standalone 64-bit Windows builds and ideally OSX builds (it's not the end of the world if it doesn't work on Mac). Our console builds do not require this.

    What is the best approach/least hacky way to accomplish this? Ideally there's some static callback made that I haven't found in my documentation searches....

    Thanks,

    George
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    If you enable "Generate Visual Studio solution"/"Generate Xcode project" option, it will generate a project for the entry point which you can modify and do your stuff there before passing control over to Unity. You can then build the executable from it and reuse for all subsequent builds, even ones without explicit project generation.
     
  3. georgehornmoen_hinterland

    georgehornmoen_hinterland

    Joined:
    Nov 12, 2020
    Posts:
    2
  4. Guitoon

    Guitoon

    Joined:
    May 1, 2019
    Posts:
    6
    Hi !

    I have the same SDK integration purposes, I need to run some custom code before the Direct3D device but I'm in 2017.4.X.

    So I checked my Build Settings window and I can't found the "Create Visual Studio Solution" option inside.

    But, currently in the 2017.4 Build Settings window documentation page, I can see an option called "Create Visual Studio Solution". Why this option isn't visible for me ?

    Has it some conditions to display this specific option in Build Window ? Or maybe for 2017.4.X, I have to do some other tricks to execute my code before Direct3D device ?

    Thanks,

    Gaëtan
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Unfortunately that option was added in Unity 2018 cycle. Does 2017.4 even have a separate UnityPlayer.dll? I don't recall when it was split out from the executable.
     
    Guitoon likes this.
  6. GaetanvergeotMDS

    GaetanvergeotMDS

    Joined:
    Sep 28, 2020
    Posts:
    2
    Thanks for your answer !

    Is there a way to create with in 2017.4 a system doing the same thing than the "Create Visual Studio Solution" option ?

    If we don't have it, can we maybe replace it ?
     
  7. GaetanvergeotMDS

    GaetanvergeotMDS

    Joined:
    Sep 28, 2020
    Posts:
    2