From 817e6fc7f30607145fd695f1f6c7c7e00e889a24 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 15 Jul 2024 22:54:02 -0700 Subject: [PATCH] fix: Leave UI when screensettings is none --- Assets/JCSUnity/Scripts/Settings/JCS_ScreenSettings.cs | 10 ++++++++++ .../Scripts/UI/GameWindow/JCS_BaseDialogueObject.cs | 2 +- Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs | 4 ++-- Assets/JCSUnity/Scripts/UI/JCS_PanelRoot.cs | 7 +++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Assets/JCSUnity/Scripts/Settings/JCS_ScreenSettings.cs b/Assets/JCSUnity/Scripts/Settings/JCS_ScreenSettings.cs index cfd5a180..b3e090b9 100644 --- a/Assets/JCSUnity/Scripts/Settings/JCS_ScreenSettings.cs +++ b/Assets/JCSUnity/Scripts/Settings/JCS_ScreenSettings.cs @@ -175,6 +175,7 @@ public bool ShouldSpawnResizablePanels() { switch (SCREEN_TYPE) { + case JCS_ScreenType.NONE: case JCS_ScreenType.FIT_ALL: case JCS_ScreenType.MIXED: return false; @@ -195,6 +196,15 @@ public bool IsResponsive() return false; } + /// + /// Return true if current screen type is none. + /// + /// + public bool IsNone() + { + return SCREEN_TYPE == JCS_ScreenType.NONE; + } + /// /// Return the starting screen size by the current screen type. /// diff --git a/Assets/JCSUnity/Scripts/UI/GameWindow/JCS_BaseDialogueObject.cs b/Assets/JCSUnity/Scripts/UI/GameWindow/JCS_BaseDialogueObject.cs index 9725c6ed..5d5d028d 100644 --- a/Assets/JCSUnity/Scripts/UI/GameWindow/JCS_BaseDialogueObject.cs +++ b/Assets/JCSUnity/Scripts/UI/GameWindow/JCS_BaseDialogueObject.cs @@ -167,7 +167,7 @@ protected void SetParentObjectByMode() Transform parentObject; // if is Resize UI is enable than add Dialogue under resize ui transform - if (JCS_UISettings.instance.RESIZE_UI) + if (JCS_UISettings.instance.RESIZE_UI && !JCS_ScreenSettings.instance.IsNone()) parentObject = resizeUI.transform; // Else we add it directly under the Canvas else diff --git a/Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs b/Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs index c8069f30..0a6b0642 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs @@ -76,7 +76,7 @@ private void Awake() this.mAppRect = this.GetComponent(); this.mCanvas = this.GetComponent(); - if (JCS_UISettings.instance.RESIZE_UI) + if (JCS_UISettings.instance.RESIZE_UI && !JCS_ScreenSettings.instance.IsNone()) { // resizable UI in order to resize the UI correctly mResizeUI = JCS_Util.Instantiate(RESIZE_UI_PATH).GetComponent(); @@ -93,7 +93,7 @@ private void Awake() private void Start() { - if (JCS_UISettings.instance.RESIZE_UI) + if (JCS_UISettings.instance.RESIZE_UI && !JCS_ScreenSettings.instance.IsNone()) { if (mResizeUI == null) return; diff --git a/Assets/JCSUnity/Scripts/UI/JCS_PanelRoot.cs b/Assets/JCSUnity/Scripts/UI/JCS_PanelRoot.cs index e1e23659..298ef1b4 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_PanelRoot.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_PanelRoot.cs @@ -42,8 +42,11 @@ protected override void Awake() { base.Awake(); - // NOTE: not sure is this the correct position for the code or not. - DoResize(); + if (!JCS_ScreenSettings.instance.IsNone()) + { + // NOTE: not sure is this the correct position for the code or not. + DoResize(); + } } protected override void Start()