From c1c8ec77cc97e63b685c9c3ca0e9a35d0edcbb8b Mon Sep 17 00:00:00 2001 From: Shimmermare Date: Mon, 14 Aug 2023 16:49:49 +0300 Subject: [PATCH 1/2] Unity version dependent style name --- Runtime/Helpers/GUIHelper.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Runtime/Helpers/GUIHelper.cs b/Runtime/Helpers/GUIHelper.cs index f1ec6d6..2eec30d 100644 --- a/Runtime/Helpers/GUIHelper.cs +++ b/Runtime/Helpers/GUIHelper.cs @@ -5,8 +5,12 @@ using UnityEngine; public static class GUIHelper - { + { + #if UNITY_2022_3_OR_NEWER + private static readonly GUIStyle _closeButtonStyle = GUI.skin.FindStyle("ToolbarSearchCancelButton"); + #else private static readonly GUIStyle _closeButtonStyle = GUI.skin.FindStyle("ToolbarSeachCancelButton"); + #endif /// Draws the close button. /// Rect the button should be located in. From b1b24e19fbf896efd2b0fb5216954cdbc7868b70 Mon Sep 17 00:00:00 2001 From: Shimmermare Date: Wed, 4 Oct 2023 17:49:06 +0300 Subject: [PATCH 2/2] Make style search work on all Unity versions --- Runtime/Helpers/GUIHelper.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Runtime/Helpers/GUIHelper.cs b/Runtime/Helpers/GUIHelper.cs index 2eec30d..7a9f094 100644 --- a/Runtime/Helpers/GUIHelper.cs +++ b/Runtime/Helpers/GUIHelper.cs @@ -6,11 +6,7 @@ public static class GUIHelper { - #if UNITY_2022_3_OR_NEWER - private static readonly GUIStyle _closeButtonStyle = GUI.skin.FindStyle("ToolbarSearchCancelButton"); - #else - private static readonly GUIStyle _closeButtonStyle = GUI.skin.FindStyle("ToolbarSeachCancelButton"); - #endif + private static readonly GUIStyle _closeButtonStyle = FindCloseButtonStyle(); /// Draws the close button. /// Rect the button should be located in. @@ -38,6 +34,17 @@ [PublicAPI] public static bool CloseButton(Rect buttonRect) /// The rectangle used inside the scrollView. public static ScrollView ScrollViewBlock(Rect position, ref Vector2 scrollPosition, Rect viewRect) => new ScrollView(position, ref scrollPosition, viewRect); + private static GUIStyle FindCloseButtonStyle() + { + // Name was changed in Unity 2023.2, 2021.3.28, 2022.3.1 + GUIStyle style = GUI.skin.FindStyle("ToolbarSearchCancelButton"); + if (style == null) + { + style = GUI.skin.FindStyle("ToolbarSeachCancelButton"); + } + return style; + } + public readonly struct ScrollView : IDisposable { public ScrollView(Rect position, ref Vector2 scrollPosition, Rect viewRect)