From 316cad109ce0154d96d59c58260808ef34897300 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Fri, 28 May 2021 17:53:29 -0700 Subject: [PATCH] Use contentScaleFactor instead of scale --- .../@babylonjs/react-native/ios/BabylonNativeInterop.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm b/Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm index 9a5f54d91..6bf0b9e58 100644 --- a/Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm +++ b/Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm @@ -55,8 +55,9 @@ + (void)onBridgeWillInvalidate:(NSNotification*)notification } + (void)updateView:(MTKView*)mtkView { - const int width = static_cast(mtkView.bounds.size.width * UIScreen.mainScreen.scale); - const int height = static_cast(mtkView.bounds.size.height * UIScreen.mainScreen.scale); + const CGFloat scale = mtkView.contentScaleFactor; + const int width = static_cast(mtkView.bounds.size.width * scale); + const int height = static_cast(mtkView.bounds.size.height * scale); if (width != 0 && height != 0) { Babylon::UpdateView((__bridge void*)mtkView, width, height); } @@ -81,7 +82,7 @@ + (bool)isXRActive { + (void)reportTouchEvent:(MTKView*)mtkView touches:(NSSet*)touches event:(UIEvent*)event { for (UITouch* touch in touches) { if (touch.view == mtkView) { - const CGFloat scale = UIScreen.mainScreen.scale; + const CGFloat scale = mtkView.contentScaleFactor; const CGPoint pointerPosition = [touch locationInView:mtkView]; const uint32_t x = static_cast(pointerPosition.x * scale); const uint32_t y = static_cast(pointerPosition.y * scale);