Skip to content

Fix incorrect editor style name for Unity 2022.3+ #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Runtime/Helpers/GUIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using UnityEngine;

public static class GUIHelper
{
private static readonly GUIStyle _closeButtonStyle = GUI.skin.FindStyle("ToolbarSeachCancelButton");
{
private static readonly GUIStyle _closeButtonStyle = FindCloseButtonStyle();

/// <summary>Draws the close button.</summary>
/// <param name="buttonRect">Rect the button should be located in.</param>
Expand Down Expand Up @@ -34,6 +34,17 @@ [PublicAPI] public static bool CloseButton(Rect buttonRect)
/// <param name="viewRect">The rectangle used inside the scrollView.</param>
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)
Expand Down