skynard
skynard

Reputation: 143

Persistance with an ARWorldMap created with ARKit through Unity

I am new to AR and using Unity, ARFoundation, and ARKit.

Will my ARWorldMaps have persistence in an outdoor or indoor experience and will it be as effective as Azure? I will only be deploying on iOS so cross-platform is not important.

Upvotes: 1

Views: 690

Answers (1)

Andy Jazz
Andy Jazz

Reputation: 58043

Saving ARWorldMap is not a rocket science. If this feature is supported in ARKit extension for Unity, ARWorldMap will be saved in any AR app the same way as expected. The main difference is that Unity builds for iOS are written in slow Objective-C, not in faster Swift for UIKit, and not in the fastest Swift for SwiftUI. In iOS for storing ARWorldMap you must use NSKeyedArchiver, and for retrieving ARWorldMap data you must use NSKeyedUnarchiver.

func writeWorldMap(_ worldMap: ARWorldMap, to url: URL) throws {

    let data = try NSKeyedArchiver.archivedData(withRootObject: worldMap, 
                                         requiringSecureCoding: true)
    try data.write(to: url)
}

ARWorldMap stores world coordinate grid, position and orientation of your device, reference snapshots of a surrounding environment and ARAnchors. It's hard to say what you mean saying ...as effective as Azure... but ARWorldMap data is the most effective offline way to store and retrieve persistence data in iOS AR apps.

Upvotes: 1

Related Questions