diff --git a/Sources/PixelKit/PIX/PIX.swift b/Sources/PixelKit/PIX/PIX.swift index bc769a8f..c54242c0 100644 --- a/Sources/PixelKit/PIX/PIX.swift +++ b/Sources/PixelKit/PIX/PIX.swift @@ -451,17 +451,29 @@ open class PIX: NODE, ObservableObject, Equatable { guard type.typeName == typeName else { continue } switch type { case .camera: + #if !os(tvOS) return try encoder.encode(pixelModel as! CameraPixelModel) + #else + throw CodingError.badOS + #endif case .image: return try encoder.encode(pixelModel as! ImagePixelModel) case .vector: + #if !os(tvOS) return try encoder.encode(pixelModel as! VectorPixelModel) + #else + throw CodingError.badOS + #endif case .video: return try encoder.encode(pixelModel as! VideoPixelModel) case .view: return try encoder.encode(pixelModel as! ViewPixelModel) case .web: + #if !os(tvOS) return try encoder.encode(pixelModel as! WebPixelModel) + #else + throw CodingError.badOS + #endif case .screenCapture: #if os(macOS) && !targetEnvironment(macCatalyst) return try encoder.encode(pixelModel as! ScreenCapturePixelModel) @@ -727,17 +739,29 @@ open class PIX: NODE, ObservableObject, Equatable { guard type.typeName == typeName else { continue } switch type { case .camera: + #if !os(tvOS) return try decoder.decode(CameraPixelModel.self, from: data) + #else + throw CodingError.badOS + #endif case .image: return try decoder.decode(ImagePixelModel.self, from: data) case .vector: + #if !os(tvOS) return try decoder.decode(VectorPixelModel.self, from: data) + #else + throw CodingError.badOS + #endif case .video: return try decoder.decode(VideoPixelModel.self, from: data) case .view: return try decoder.decode(ViewPixelModel.self, from: data) case .web: + #if !os(tvOS) return try decoder.decode(WebPixelModel.self, from: data) + #else + throw CodingError.badOS + #endif case .screenCapture: #if os(macOS) && !targetEnvironment(macCatalyst) return try decoder.decode(ScreenCapturePixelModel.self, from: data) @@ -998,17 +1022,29 @@ open class PIX: NODE, ObservableObject, Equatable { guard type.typeName == typeName else { continue } switch type { case .camera: + #if !os(tvOS) return CameraPIX(model: pixelModel as! CameraPixelModel) + #else + throw CodingError.badOS + #endif case .image: return ImagePIX(model: pixelModel as! ImagePixelModel) case .vector: + #if !os(tvOS) return VectorPIX(model: pixelModel as! VectorPixelModel) + #else + throw CodingError.badOS + #endif case .video: return VideoPIX(model: pixelModel as! VideoPixelModel) case .view: return ViewPIX(model: pixelModel as! ViewPixelModel) case .web: + #if !os(tvOS) return WebPIX(model: pixelModel as! WebPixelModel) + #else + throw CodingError.badOS + #endif case .screenCapture: #if os(macOS) && !targetEnvironment(macCatalyst) return ScreenCapturePIX(model: pixelModel as! ScreenCapturePixelModel) diff --git a/Sources/PixelKit/PIX/PIXType.swift b/Sources/PixelKit/PIX/PIXType.swift index 33636154..9d508c41 100644 --- a/Sources/PixelKit/PIX/PIXType.swift +++ b/Sources/PixelKit/PIX/PIXType.swift @@ -238,16 +238,22 @@ public enum PIXType: Equatable, CaseIterable { return generator.type.init(at: resolution) case .resource(let resource): if resource == .web { + #if !os(tvOS) return WebPIX(at: resolution) + #else + return nil + #endif } if resource == .maps { return EarthPIX(at: resolution) } - #if os(iOS) && !targetEnvironment(simulator) if resource == .paint { + #if os(iOS) && !targetEnvironment(simulator) return PaintPIX(at: resolution) + #else + return nil + #endif } - #endif guard let pix = resource.type?.init() else { return nil } precondition(pix is NODEResolution == false) return pix @@ -301,22 +307,32 @@ public enum PIXType: Equatable, CaseIterable { return true case .resource(let resource): if resource == .web { + #if !os(tvOS) guard let webPix = pix as? WebPIX else { return false } webPix.resolution = resolution return true + #else + return false + #endif } - #if os(iOS) && !targetEnvironment(simulator) if resource == .web { + #if os(iOS) && !targetEnvironment(simulator) guard let paintPix = pix as? PaintPIX else { return false } paintPix.resolution = resolution return true + #else + return false + #endif } - #endif if resource == .camera { + #if !os(tvOS) guard let cameraPix = pix as? CameraPIX else { return false } guard let cameraResolution = CameraPIX.CameraResolution(resolution: resolution) else { return false } cameraPix.cameraResolution = cameraResolution return true + #else + return false + #endif } return false case .sprite: diff --git a/Sources/PixelKit/PIX/PIXs/Content/Resource/Camera/CameraPixelModel.swift b/Sources/PixelKit/PIX/PIXs/Content/Resource/Camera/CameraPixelModel.swift index eef856ab..b2fb42fe 100644 --- a/Sources/PixelKit/PIX/PIXs/Content/Resource/Camera/CameraPixelModel.swift +++ b/Sources/PixelKit/PIX/PIXs/Content/Resource/Camera/CameraPixelModel.swift @@ -2,6 +2,8 @@ // Created by Anton Heestand on 2021-12-21. // +#if !os(tvOS) + import Foundation import CoreGraphics import RenderKit @@ -91,3 +93,4 @@ extension CameraPixelModel { } } +#endif