SKTexture from the texture(from:crop:) method doesn't change with changes in crop CGRect

We are trying to generate an SKTexture (texture) from the rendering of an SKNode (node) in an SKScene presented to an SKView (view)


let origin = CGPoint (x:0, y:0)
let rect = CGRect(origin:origin, size:CGSize(width:100, height:100))
let texture = view?.texture(from:node, crop:rect)


The resulting texture is always the same regardless of the origin value.

Has anybody ran into this issue before?

Accepted Reply

Well, this problem is related to using the SKScene (which is the root node of the scene) as the node to crop. This seems to be a known Apple bug (#29005461) that was submitted on 2016 and it seems it has never been fixed (Wow! 3 years. Every place that I have worked in, a bug this serious that hasn't been solved for 3 years is unheard of and totally unacceptable). There is a workaround, you have to create your own root SKnode and use the method on that node instead.

Replies

Well, this problem is related to using the SKScene (which is the root node of the scene) as the node to crop. This seems to be a known Apple bug (#29005461) that was submitted on 2016 and it seems it has never been fixed (Wow! 3 years. Every place that I have worked in, a bug this serious that hasn't been solved for 3 years is unheard of and totally unacceptable). There is a workaround, you have to create your own root SKnode and use the method on that node instead.