Creating Windows Universal Plugin for Unity
Hi there,
I've created a Universal Windows plugin for Unity that I would like to use in my Windows Universal Platform builds. It's Windows Runtime Component compliant, with the exception of the Unity code itself which isn't, namely the MonoBehaviour class which can't be inherited from. I fixed this just by changing the Output type to Class Library.
So essentially, I have a Windows Universal class library. I've placed a copy in the following folders,
Assets\Plugins\x86\…
and
Assets\Plugins\x86_64\…
I've then changed the properties for the plugin inside Unity so that it is only supported by the WSAPlayer, and set the SDK to UWP, this is essential as I'm using UWP specific classes from the runtime.
Anyway, so what now? I understand that I should now be able to use the library in my scripts. I can't see it in the references in order to add a using statement for it, nor can I add it manually as I get a weird error...
Any ideas what I've done wrong and how I can use this plugin? I've tried changing the player .NET runtime to experimental 4.5, which is not really relevant I know as UWP does not use the .NET Framework, but a subset.
Any help would be greatly appreciated as I'm stuck.
Many thanks.
Edit:
According to the documentation on this page,
https://docs.unity3d.com/Manual/windowsstore-plugins.html
I need to create a placeholder plugin, compiled against .NET 3.5.... Ermm, how exactly? My Plug-In is compiled for UWP, the API's are not even in .NET 3.5, if I could compile to .NET 3.5 I wouldn't even be bothering with UWP at the moment.
Are UWP plugins properly supported or is this just some kind of interim bodge?
Answer by firkinfedup · May 07, 2018 at 08:46 AM
Okay, so here's the deal, you can hide all of your wizzy UWP code inside your plugin. But you have to make a .NET 3.5 copy of the plugin with just interfaces declared, no method body code etc. This will require that you remove any UWP-only classes from method signatures etc. The editor will then use this version of the library when writing scripts and running in the editor. When running in your chosen build, it will use the library of the same name / version found the relevant platform path.
Your answer
Follow this Question
Related Questions
[UWP]WebRTC issue - Hololens unable to send video offer 1 Answer
Finding and editing private objects with plugins in c# 0 Answers
Which is the easiest way to access google play games services from our game ? 0 Answers
URP spotlights and point lights do not cast shadows 0 Answers
Marshal C# Method with C++ 0 Answers