Search Unity

Getting Unity build to edit WSA project's Package.appxmanifest XML file

Discussion in 'Windows' started by dumbledad, Jun 23, 2017.

  1. dumbledad

    dumbledad

    Joined:
    Feb 11, 2016
    Posts:
    7
    I have a Unity project that connects to a custom peripheral over serial over USB. The app works fine in the Unity editor, and fine as a standalone Win32 app, but until just now the UWP version would crash if the peripheral was connected. The crash message was pretty cryptic:

    I've tracked down the problem. I need to edit the Package.appmanifest XML file to include this in the <DeviceCapability Name="humaninterfacedevice"> section:

    Code (csharp):
    1. <Device Id="vidpid:045E DCDC">
    2.     <Function Type="usage:FFAB 0200" />
    3. </Device>
    (N.B. 'vidpid' is the vendor id & product id for my peripheral, I might be able to just use "any" instead.)

    Is there a way to get the Unity build process for WSA to handle editing to insert that device usage? I'd like to package this up and it would be great if people using my API did not have to hand edit the XML file.
     
    Last edited: Jun 23, 2017
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    In the editor script before building the project, you could use PlayerSettings.WSA.SetCapability API to make us emit the humaninterfacedevice capability into the manifest. But it will not emit your custom device. For that, you could implement this interface:

    https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuild.OnPostprocessBuild.html

    and then inject that device into the manifest.

    However, crashing is not normal. I understand that this only happens with your custom peripheral device? In the generated VS project, could you go to its properties, debug tab, and select "Mixed mode debugging". Then, open Debug -> Windows -> Exceptions, and in the opened window, make sure "C++ Exceptions" are checked. Then, run the game. There will be several exceptions happening before Platform::InvalidArgumentException - just ignore them by continuing once they get thrown. Once you hit this exception, go to Debug -> Save Dump As.... Finally, can you send the resulting file via PM to me?