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);