Skip to content
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

FIX: UI generation of custom interactions of action properties when it rely on OnGUI callback (ISXB-886) #1957

Merged
merged 9 commits into from
Jun 30, 2024
2 changes: 2 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ however, it has to be formatted properly to pass verification tests.
- Fixed a performance issue with many objects using multiple action maps [ISXB-573](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-573).
- Fixed an variable scope shadowing issue causing compilation to fail on Unity 2019 LTS.
- Fixed an issue where changing `InputSettings` instance would not affect associated feature flags.
- Fixed the UI generation of enum fields when editing interactions of action properties. The new selected value was lost when saving.
- Fixed the UI generation of custom interactions of action properties when it rely on OnGUI callback. [ISXB-886](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-886).

### Added
- Added additional device information when logging the error due to exceeding the maximum number of events processed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ protected override void OnEnable()

public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
m_PressPointSetting.OnGUI();
m_DurationSetting.OnGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ protected override void OnEnable()

public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount);
m_TapDelaySetting.OnGUI();
m_TapTimeSetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ protected override void OnEnable()

public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
EditorGUILayout.HelpBox(s_HelpBoxText);
target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior);
m_PressPointSetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ protected override void OnEnable()

public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ protected override void OnEnable()

public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void OnEditEnd()
{
var intValue = parameter.value.value.ToInt32();
var field = new DropdownField(label.text, parameter.enumNames.Select(x => x.text).ToList(), intValue);
field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex));
field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, field.index, closedIndex));
field.RegisterCallback<BlurEvent>(_ => OnEditEnd());
root.Add(field);
}
Expand Down Expand Up @@ -350,6 +350,10 @@ public void OnGUI()
return;
}

#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
// handled by OnDrawVisualElements with UI Toolkit
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
#endif
// Otherwise, fall back to our default logic.
if (m_Parameters == null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public NameAndParametersListViewItem(VisualElement root, ParameterListView param
var foldout = container.Q<Foldout>("Foldout");
foldout.text = parameterListView.name;
parameterListView.OnDrawVisualElements(foldout);

foldout.Add(new IMGUIContainer(() => parameterListView.OnGUI()));
}
}
}
Expand Down