Shane O'Seasnain Shane O'Seasnain - 2 months ago 19
Swift Question

what replaces init(name:float:) now that it has been deprecated

I'm getting a warning that

init(name:float:)
has been deprecated with Swift3. Does anyone know what has replaced it?

The problem came up in a shader:

SKUniform(name: "size",
float:GLKVector3Make(
Float(self.frame.size.width),
Float(self.frame.size.height), 0)),

Answer

From the iOS 10 Release Notes:

iOS 10 deprecates several APIs, including:

...

Several SKUniform symbols related to floating point values. Instead, use methods such as initWithName:vectorFloat2: and uniformWithName:matrixFloat2x2:, as appropriate.

For example:

SKUniform(name: "size", 
          vectorFloat2:vector2(
            Float(self.frame.size.width), 
            Float(self.frame.size.height)
          ))
Comments