3

I have developed an iOS/ARKit app that functions as a content editor for my AR game. It has a fair amount of interface that I don't want to port over to Unity, but I want to be able to save my ARWorldMaps from the iOS editor app and load them into my Unity AR game.

I'm using NSKeyedArchiver to serialize my ARWorldMap like this:

func serializeMap(_ worldMap: ARWorldMap) -> Data {
    return try! NSKeyedArchiver.archivedData(withRootObject: worldMap, requiringSecureCoding: true)
}

Any ideas how I could use those bytes returned from serializeMap to load the map in Unity using ARWorldMap.TryDeserialize?

ezpz
  • 31
  • 4
  • Are the two types compatible and interoperable? If so, you should be able to save the archive to disk and then lid it from unity. – Lior Pollak Apr 23 '22 at 15:09
  • @ezpz, read my answer – https://stackoverflow.com/questions/52075159/arkit-cannot-decode-aranchor-in-mcsession/62596832#62596832 – Andy Jazz May 08 '22 at 07:15

1 Answers1

1

It should look rather like

func deserializeMap(_ data: Data) -> ARWorldMap? {
    return try? NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: data)
}
Asperi
  • 228,894
  • 20
  • 464
  • 690