CocoaMilka
CocoaMilka

Reputation: 97

Unity UWP Vector3 AOT code not generated, JSON serialization

I'm working on a Unity project for the Hololens 2 which serializes user data and saves it as a json file to be accessed again later. What I have currently works fine when emulating in Unity but on the Hololens itself I get the following error when serializing:

ExecutionEngineException: Attempting to call method 'System.Runtime.Serialization.XmlObjectSerializerWriteContext::IncrementCollectionCountGeneric<UnityEngine.Vector3>' for which no ahead of time (AOT) code was generated.

After some testing I've found that my code works fine on the Hololens as long as I don't use any Vector3's which makes sense considering the error above. The issue I'm having is when Vector3 is being serialized in the json file it will simply cut off and leave incomplete json. I assume the issue is because of the missing method for serializing Vector3's when building for the Hololens (UWP).

How should I go about handling this from here?

Upvotes: 0

Views: 139

Answers (1)

CocoaMilka
CocoaMilka

Reputation: 97

Unity strips code when building for platforms with AOT support (such as UWP which the Hololens uses) and this has a tendency to not generate AOT code that should be generated like the serialization code for my project. At the time I was using data contracts but switching over to json.net solved all of my problems.

Upvotes: 0

Related Questions