Skip to content

Commit

Permalink
feat: Added EditorGUIHelper.HasKeyboardFocus(int controlID) method
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidAlloy committed Apr 30, 2021
1 parent 414909d commit 9428a87
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
11 changes: 11 additions & 0 deletions Editor/Helpers/EditorGUIHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SolidUtilities.Editor.Helpers
{
using JetBrains.Annotations;

public static class EditorGUIHelper
{
[PublicAPI]
public static bool HasKeyboardFocus(int controlID)
=> UnityEditorInternals.EditorGUIHelper.HasKeyboardFocus(controlID);
}
}
3 changes: 3 additions & 0 deletions Editor/Helpers/EditorGUIHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityEditorInternals.dll
Binary file not shown.
Binary file modified UnityEditorInternals2019.dll
Binary file not shown.
10 changes: 6 additions & 4 deletions UnityInternals~/UnityEditorInternals/EditorGUIHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if UNITY_2020
namespace SolidUtilities.UnityEditorInternals
namespace SolidUtilities.UnityEditorInternals
{
using System;
using UnityEditor;
Expand All @@ -8,6 +7,9 @@ namespace SolidUtilities.UnityEditorInternals

public static class EditorGUIHelper
{
public static bool HasKeyboardFocus(int controlID) => EditorGUI.HasKeyboardFocus(controlID);

#if UNITY_2020
// I've seen a lot of ugly methods in Unity source code, but this is just.. OMG
// The method is identical to the original, only non-delayed fields are replaced with their delayed versions where possible.
// For SerializedPropertyType.Integer, there is also a ternary expression instead of a single LongField because a version of DelayedLongField doesn't exist.
Expand Down Expand Up @@ -301,6 +303,6 @@ public static bool DefaultPropertyFieldDelayed(Rect position, SerializedProperty

return childrenAreExpanded;
}
#endif
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private static void OnGUISafeExtended(this PropertyDrawer propertyDrawer, Rect p
ScriptAttributeUtility.s_DrawerStack.Pop();
}

// Only EditorGUI.DefaultPropertyField is replaced with EditorGUIHelper.DefaultPropertyFieldDelayed
// EditorGUI.DefaultPropertyField is replaced with EditorGUIHelper.DefaultPropertyFieldDelayed
// propertyDrawer.OnGUISafe is replaced with propertyDrawer.OnGUISafeExtended
private static bool OnGUIDelayed(this PropertyHandler handler, Rect position, SerializedProperty property,
GUIContent label, bool includeChildren)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'Unity2019'">
<Reference Include="UnityEditor">
<HintPath>C:\Program Files\Unity Editors\2019.4.12f1\Editor\Data\Managed\UnityEngine\UnityEditor.dll</HintPath>
<HintPath>C:\Program Files\Unity Editors\2019.4.24f1\Editor\Data\Managed\UnityEngine\UnityEditor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DrawerReplacer.cs" />
<Compile Include="EditorGUIHelper.cs" />
<Compile Include="EditorGUILayoutHelper.cs" />
<Compile Include="EditorGUISlider.cs" />
<Compile Include="EditorGUIUtilityProxy.cs" />
<Compile Include="IDelayable.cs" />
<Compile Include="LogEntries.cs" />
Expand Down

0 comments on commit 9428a87

Please sign in to comment.