I am trying to take a snapshot of a SKScene and have hit a catch-22
I am attempting to call this after creating the view and adding a bunch of sprites (I need to make a thumbnail picture)
UIGraphicsBeginImageContextWithOptions(r.size,false, 1)
spriteLAYER.scene?.view?.drawHierarchy(in: r, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
If afterScreenUpdates is false I get this error
[Snapshotting] Drawing a view (spriteView) that has not been rendered at least once requires afterScreenUpdates:YES.
if it is True , then I get this
[Snapshotting] View (spriteView) drawing with afterScreenUpdates:YES inside CoreAnimation commit is not supported.
I have tried calling this routine from various places… all with the same results
This code kinda works… but it doesn’t honor the rotation of the sprites in the resulting image
let texture : SKTexture = spriteLAYER.texture(from: spriteLAYER.scene!)!
let image : UIImage =UIImage(cgImage: texture.cgImage())