|
| 1 | +# Workaround for UWP (Universal Windows Platform) |
| 2 | + |
| 3 | +Latest windows store uses UWP for building an app. |
| 4 | +Unlike regular Unity apps, app for UWP uses dedicated .NET framework which is |
| 5 | +not compatible with Unity3D-Mono framework. |
| 6 | + |
| 7 | +## What's the problem? |
| 8 | + |
| 9 | +When you try to build app using Json.NET.Unity3D for Windows Store, |
| 10 | +you will get following errors: |
| 11 | + |
| 12 | +``` |
| 13 | +UnityException: Failed to run serialization weaver with command ... |
| 14 | +(stripped) |
| 15 | +
|
| 16 | +Mono.Cecil.ResolutionException: |
| 17 | + Failed to resolve System.Runtime.Serialization.Formatters.FormatterAssemblyStyle |
| 18 | +(stripped) |
| 19 | +``` |
| 20 | + |
| 21 | +UAP doesn't have enum `FormatterAssemblyStyle` in its assembly and |
| 22 | +it should be added to run on windows store. |
| 23 | + |
| 24 | +## How to fix? |
| 25 | + |
| 26 | +It's simple. Use original [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/) |
| 27 | +which contains a DLL for UWP. |
| 28 | + |
| 29 | + 1. Import [Json.Net.Unity3D](https://github.com/SaladLab/Json.Net.Unity3D/releases/download/8.0.3/JsonNet.8.0.3.unitypackage) |
| 30 | + unity package. |
| 31 | + 1. Create `Assets/UnityPackages/JsonNet/Portable` directory in unity project. |
| 32 | + 1. Download [Newtonsoft.Json](https://www.nuget.org/api/v2/package/Newtonsoft.Json/8.0.3) |
| 33 | + nuget package and extract it as a zip file. |
| 34 | + 1. Copy `./lib/portable-net45%2Bwp80%2Bwin8%2Bwpa81%2Bdnxcore50/Newtonsoft.Json.dll` |
| 35 | + in the nuget package to `Assets/UnityPackages/JsonNet/Portable` directory. |
| 36 | + 1. Watch `Assets/UnityPackages/JsonNet/Newtonsoft.Json.dll` with an inspector, |
| 37 | + uncheck `Any Platform` at Select platforms for plugin |
| 38 | + and Set all platforms checked except `WSAPlayer`. |
| 39 | + 1. Watch `Assets/UnityPackages/JsonNet/Portable/Newtonsoft.Json.dll` with an inspector, |
| 40 | + uncheck `Any Platform` at Select platforms for plugin |
| 41 | + and set only `WSAPlayer` checked. |
| 42 | + |
| 43 | +Done! |
0 commit comments