From 7444be3e9dd131db15d74648e0c46a7b9f200a55 Mon Sep 17 00:00:00 2001 From: matiascodesal Date: Fri, 9 Sep 2022 22:18:36 -0400 Subject: [PATCH] fixed on_window_changed errors --- .../maticodes/viewport/reticle/views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/exts/maticodes.viewport.reticle/maticodes/viewport/reticle/views.py b/exts/maticodes.viewport.reticle/maticodes/viewport/reticle/views.py index 9fc56f2..4e54238 100644 --- a/exts/maticodes.viewport.reticle/maticodes/viewport/reticle/views.py +++ b/exts/maticodes.viewport.reticle/maticodes/viewport/reticle/views.py @@ -63,15 +63,20 @@ def destroy(self): def on_window_changed(self, *args): """Update aspect ratio and rebuild overlay when viewport window changes.""" + if self.vp_win is None: + return + settings = carb.settings.get_settings() - fill = settings.get(constants.SETTING_RESOLUTION_FILL) + if type(self.vp_win).__name__ == "LegacyViewportWindow": + fill = settings.get(constants.SETTING_RESOLUTION_FILL) + else: + fill = self.vp_win.viewport_api.fill_frame + if fill: width = self.vp_win.frame.computed_width + 8 height = self.vp_win.height else: - res = self.vp_win.viewport_api.resolution - width = res[0] - height = res[1] + width, height = self.vp_win.viewport_api.resolution self._aspect_ratio = width / height self.build_viewport_overlay()