Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can ENABLE_WINMD_SUPPORT be used with a standalone application?

Discussion in 'Scripting' started by joshuajnoble, Aug 24, 2020.

  1. joshuajnoble

    joshuajnoble

    Joined:
    May 21, 2020
    Posts:
    3
    I'm trying to explore building in device support via systems level functions on Windows (stuff contained in Windows.Devices). I read in this thread that you can link systems functions and more generally capabilities from windows.winmd by using this flag. However, even having a simple statment like:

    #if ENABLE_WINMD_SUPPORT
    Debug.Log("WINMD");
    #endif

    isn't being triggered. My goal would be to not have to generate a UWP app, I'd rather have users just make a Standalone app that uses system devices. I currently have my target platform set to Windows and the scripting backend set as "IL2CPP" with the Api Compatibility Level set to ".NET 4.x". Is using the "Windows." namespace possible in a standalone app? If so is there anything else I need to do? Thanks much for guidance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    Are you defining the
    ENABLE_WINMD_SUPPORT
    symbol before compilation? You can do this in the PlayerSettings page in Unity. That type of flag is evaluated at compile time and never again after that.

    Also, if you want to access functions that are not part of Unity's libraries, you would need to get the appropriate DLLs for those functions into your project as well, obviously.
     
    joshuajnoble likes this.
  3. joshuajnoble

    joshuajnoble

    Joined:
    May 21, 2020
    Posts:
    3
    Thanks for reponse! I did set ENABLE_WINMD_SUPPORT in the compilation flags but it leads to errors in the Unity IDE (though not in Visual Studio if I compile there). Is the idea that I place copies of all the system DLLs in the Assets/Plugins?
     
    Last edited: Aug 25, 2020
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    It is more than the idea: it is a very specific set of criteria that must be met in order for the code to be found, linked, started and executed.

    I recommend starting with whatever docs you can find with google that you feel most comfortable about regarding Unity and external or third party libraries. I don't keep up on that stuff much myself, but the concept doesn't go away.
     
  5. joshuajnoble

    joshuajnoble

    Joined:
    May 21, 2020
    Posts:
    3
    Interesting, and I guess I could see how the my use of idiomatic English may be confusing. Generally Windows (when using VS/VS-Code) has you compile against one windows.winmd that lives in the Windows Kits directory rather than having multiple copies of it (and all the other system DLLs) floating around all across the operating system to access at runtime. I've built a C# native app that does everything I want to do, so I tried copying all the DLLs which I've referenced in that VS .sln into Assets/Plugins/Windows but it doesn't seem to work. If anyone has suggestions or a pointer to a specific place in the documentation I might get some clarification I'd appreciate it a lot.