Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
110e5c6
ISXB-543 Implemented custom drawer base for enums as well as on spe…
adrian-koretski-unity3d Aug 7, 2024
50f2a47
Removed custom enum drawer.
adrian-koretski-unity3d Aug 13, 2024
4035fe5
Added changes to changelog.
adrian-koretski-unity3d Aug 13, 2024
60640fb
Merge branch 'develop' into isxb-543
adrian-koretski-unity3d Aug 13, 2024
3044d28
Re-added aliased enums into GamepadButton for compatibility with exis…
adrian-koretski-unity3d Aug 14, 2024
6e50417
Merge branch 'develop' of https://github.com/Unity-Technologies/Input…
adrian-koretski-unity3d Sep 9, 2024
e09b575
Ran the formatter on commit changes.
adrian-koretski-unity3d Sep 9, 2024
a964957
Merge branch 'develop' into isxb-543
adrian-koretski-unity3d Sep 10, 2024
806f943
Merge branch 'develop' into isxb-543
adrian-koretski-unity3d Sep 12, 2024
1318c70
Revert "ISXB-543 Implemented custom drawer base for enums as well a…
adrian-koretski-unity3d Sep 13, 2024
5f1b160
Merge branch 'isxb-543' of https://github.com/Unity-Technologies/Inpu…
adrian-koretski-unity3d Sep 13, 2024
e7e69d3
Reworked GpadButtonPropertyDrawer according to feedback.
adrian-koretski-unity3d Sep 16, 2024
d85c1ed
Merge branch 'develop' into isxb-543
adrian-koretski-unity3d Sep 18, 2024
dd2de37
Fixed GamepadButtonPropertyDrawer issues based on PR feedback.
adrian-koretski-unity3d Sep 18, 2024
d3fa10e
Moved changelog entry for ISXB-543 into correct version and added lin…
adrian-koretski-unity3d Sep 19, 2024
fc85832
Changed jira link in changelog for ISXB-543 to public issue tracker.
adrian-koretski-unity3d Sep 19, 2024
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
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ however, it has to be formatted properly to pass verification tests.

### Changed
- Renamed editor Resources directories to PackageResources to fix package validation warnings.
- Changed representation of GamepadButton enum values in Inspector to display aliased enum values as a single item to avoid confusion around selection and aliased value display when multiple enum items map to the same numerical value. [ISXB-543](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-543)

## [1.11.0] - 2024-09-10

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#if UNITY_EDITOR

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.InputSystem.LowLevel;
using UnityEditor;
using UnityEngine.UIElements;

namespace UnityEngine.InputSystem.Editor
{
/// <summary>
/// Property drawer for <see cref = "GamepadButton" />
/// </summary >
[CustomPropertyDrawer(typeof(GamepadButton))]
internal class GamepadButtonPropertyDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
CreateEnumList();
return base.CreatePropertyGUI(property);
}

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);

if (m_EnumDisplayNames == null)
{
CreateEnumList();
}

if (property.propertyType == SerializedPropertyType.Enum)
{
property.intValue = EditorGUI.Popup(position, label.text, property.intValue, m_EnumDisplayNames);
}

EditorGUI.EndProperty();
}

private void CreateEnumList()
{
var enumNamesAndValues = new Dictionary<string, int>();
var enumDisplayNames = Enum.GetNames(typeof(GamepadButton));
var enumValues = Enum.GetValues(typeof(GamepadButton)).Cast<GamepadButton>().ToArray();

for (var i = 0; i < enumDisplayNames.Length; ++i)
{
string enumName;
switch (enumDisplayNames[i])
{
case nameof(GamepadButton.Y):
case nameof(GamepadButton.Triangle):
case nameof(GamepadButton.A):
case nameof(GamepadButton.Cross):
case nameof(GamepadButton.B):
case nameof(GamepadButton.Circle):
case nameof(GamepadButton.X):
case nameof(GamepadButton.Square):
continue;
case nameof(GamepadButton.North):
enumName = "North, Y, Triangle, X";
break;
case nameof(GamepadButton.South):
enumName = "South, A, Cross, B";
break;
case nameof(GamepadButton.East):
enumName = "East, B, Circle, A";
break;
case nameof(GamepadButton.West):
enumName = "West, X, Square, Y";
break;
default:
enumName = enumDisplayNames[i];
break;
}
enumNamesAndValues.Add(enumName, (int)enumValues.GetValue(i));
}
var sortedEntries = enumNamesAndValues.OrderBy(x => x.Value);

m_EnumDisplayNames = sortedEntries.Select(x => x.Key).ToArray();
}

private string[] m_EnumDisplayNames;
}
}
#endif // UNITY_EDITOR

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