r/UnityHelp • • 3d ago

Unity 7 and windows APIs

Hello, with Unity 7, when targeting windows standalone, will we be able to consume WinRT APIs directly with C# like UWP or regular WinRT apps, or native C++/WinRT plugins will still be required?

2 Upvotes

5 comments sorted by

1

u/kurobaralabs 1d ago

I have no experience in the space, but from what I gather it looks like you can already call directly if you are building for UWP: https://docs.unity.com/en-us/engine/7000.0/manual/platform-specific/windows-store/uwp-developing/windowsstore-scripts

If you are not building for UWP, ie. building a regular windows standalone program, you will probably still need to use native plugins.

1

u/Full-Meringue-5849 1d ago

Yes, you can do it already when targeting UWP, but not windows standalone.

Normally when you add this nuget https://www.nuget.org/packages/Microsoft.Windows.SDK.Contracts to your .net app you can call windows APIs, but this package is not compatible with Unity, I suspect because it uses Mono for .net runtime. I thought if Unity finally switches to CoreCLR this would work.

I was curious if someone could confirm it.

1

u/Devatator_ 1d ago

In theory it could work, doesn't hurt to try it with NugetForUnity

1

u/Full-Meringue-5849 1d ago

I am using that nuget for unity. Including.dll did not work either.

1

u/Devatator_ 1d ago

Uh. Interesting. Can you manually do a DllImport of the system libraries? I think that should work, saw that in a few plugins before