Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ however, it has to be formatted properly to pass verification tests.
- Pinned Touch Samples sample package dependencies to avoid errors with Cinemachine 3.x and Probuilder 6.x. [ISXB-1245](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1245)
- Fixed issue where a binding path is sometimes not saved when chosen from the binding path picker. [ISXB-1221](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1221)
- Fixed an issue where dropdown menu for Path in Input Actions Editor could not be selected from any button position. [ISXB-1309](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1309)
- Fixed an issue where changing Input System default parameter settings with the editor open would result in changes in the editor. [ISXB-1351](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1351)

## [1.12.0] - 2025-01-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ public void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
value = m_DefaultInitializedValue;

var container = new VisualElement();
var settingsContainer = new VisualElement { style = { flexDirection = FlexDirection.Row } };
container.RegisterCallback<AttachToPanelEvent>(OnAttachToPanel);
container.RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);

var settingsContainer = new VisualElement { style = { flexDirection = FlexDirection.Row } };

m_FloatField = new FloatField(m_ValueLabel.text) { value = value };
m_FloatField.Q("unity-text-input").AddToClassList("float-field");
Expand All @@ -260,7 +262,6 @@ public void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
m_DefaultToggle.RegisterValueChangedCallback(evt => ToggleUseDefaultValue(evt, onChangedCallback));
m_DefaultToggle.Q<Label>().style.minWidth = new StyleLength(StyleKeyword.Auto);


var buttonContainer = new VisualElement
{
style =
Expand All @@ -286,22 +287,28 @@ public void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
root.Add(container);
}

private void ChangeSettingValue(ChangeEvent<float> evt)
private void OnAttachToPanel(AttachToPanelEvent evt)
{ // Monitor changes to settings for as long as the panel is attached to a visual tree
InputSystem.onSettingsChange += InputSystemOnSettingsChange;
}

private void OnDetachFromPanel(DetachFromPanelEvent evt)
{ // Stop monitoring changes to settings when panel is no longer part of a visual tree
InputSystem.onSettingsChange -= InputSystemOnSettingsChange;
}

private void InputSystemOnSettingsChange()
{
if (m_UseDefaultValue) return;
// Default value may change at any point settings are modified so fetch current default value
// if currently configured to display default value and having default coming from settings.
if (m_FloatField != null && m_UseDefaultValue && m_DefaultComesFromInputSettings)
m_FloatField.value = m_GetDefaultValue();
}

// ReSharper disable once CompareOfFloatsByEqualityOperator
if (evt.newValue == m_DefaultInitializedValue)
{
// If user sets a value that is equal to default initialized, change value slightly so it doesn't pass potential default checks.
////TODO: refactor all of this to use tri-state values instead, there is no obvious float value that we can use as default (well maybe NaN),
////so instead it would be better to have a separate bool to show if value is present or not.
m_SetValue(evt.newValue + float.Epsilon);
}
else
{
m_SetValue(evt.newValue);
}
private void ChangeSettingValue(ChangeEvent<float> evt)
{
if (!m_UseDefaultValue)
SetValue(evt.newValue);
}

private void OnEditEnd(Action onChangedCallback)
Expand All @@ -322,6 +329,21 @@ private void ToggleUseDefaultValue(ChangeEvent<bool> evt, Action onChangedCallba
}

#endif
private void SetValue(float newValue)
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (newValue == m_DefaultInitializedValue)
{
// If user sets a value that is equal to default initialized, change value slightly so it doesn't pass potential default checks.
////TODO: refactor all of this to use tri-state values instead, there is no obvious float value that we can use as default (well maybe NaN),
////so instead it would be better to have a separate bool to show if value is present or not.
m_SetValue(newValue + float.Epsilon);
}
else
{
m_SetValue(newValue);
}
}

public void OnGUI()
{
Expand All @@ -342,16 +364,7 @@ public void OnGUI()
////TODO: use slider rather than float field
var newValue = EditorGUILayout.FloatField(m_ValueLabel, value, GUILayout.ExpandWidth(false));
if (!m_UseDefaultValue)
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (newValue == m_DefaultInitializedValue)
// If user sets a value that is equal to default initialized, change value slightly so it doesn't pass potential default checks.
////TODO: refactor all of this to use tri-state values instead, there is no obvious float value that we can use as default (well maybe NaN),
////so instead it would be better to have a separate bool to show if value is present or not.
m_SetValue(newValue + float.Epsilon);
else
m_SetValue(newValue);
}
SetValue(newValue);

EditorGUI.EndDisabledGroup();

Expand Down