Skip to content

Commit 359f03d

Browse files
committed
Fix test failures and compiler errors.
1 parent 8bc3ef0 commit 359f03d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Assets/Tests/InputSystem.Editor/CustomProcessorEnumTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
1+
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS && UNITY_6000_0_OR_NEWER
22

33
using System;
44
using NUnit.Framework;
@@ -29,6 +29,7 @@ static CustomProcessor()
2929
{
3030
Initialize();
3131
}
32+
3233
#endif
3334

3435
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
@@ -54,7 +55,7 @@ public override void OneTimeSetUp()
5455

5556
var actionMap = m_Asset.AddActionMap("Action Map");
5657

57-
actionMap.AddAction("Action", InputActionType.Value, processors: "Custom(SomeEnum=10)");
58+
actionMap.AddAction("Action", InputActionType.Value, processors: "Custom(SomeEnum=10)");
5859
}
5960

6061
public override void OneTimeTearDown()
@@ -68,21 +69,21 @@ public override IEnumerator UnitySetup()
6869
m_Window = InputActionsEditorWindow.OpenEditor(m_Asset);
6970
yield return base.UnitySetup();
7071
}
71-
72+
7273
[UnityTest]
7374
public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
7475
{
7576
// Serialize current asset to JSON, and check that initial JSON contains default enum value for OptionA
7677
var json = m_Window.currentAssetInEditor.ToJson();
77-
78+
7879
Assert.That(json.Contains("Custom(SomeEnum=10)"), Is.True,
7980
"Serialized JSON does not contain the expected custom processor string for OptionA.");
8081

8182
// Query the dropdown with exactly two enum choices and check that the drop down is present in the UI
8283
var dropdownList = m_Window.rootVisualElement.Query<DropdownField>().Where(d => d.choices.Count == 2).ToList();
8384
Assume.That(dropdownList.Count > 0, Is.True, "Enum parameter dropdown not found in the UI.");
8485

85-
// Determine the new value to be set in the dropdown, focus the dropdown before dispatching the change
86+
// Determine the new value to be set in the dropdown, focus the dropdown before dispatching the change
8687
var dropdown = dropdownList.First();
8788
var newValue = dropdown.choices[1];
8889
dropdown.Focus();
@@ -92,7 +93,7 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
9293
var changeEvent = ChangeEvent<Enum>.GetPooled(SomeEnum.OptionA, SomeEnum.OptionB);
9394
changeEvent.target = dropdown;
9495
dropdown.SendEvent(changeEvent);
95-
96+
9697
// Find the save button in the window, focus and click the save button to persist the changes
9798
var saveButton = m_Window.rootVisualElement.Q<Button>("save-asset-toolbar-button");
9899
Assume.That(saveButton, Is.Not.Null, "Save Asset button not found in the UI.");
@@ -109,4 +110,3 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
109110
}
110111
}
111112
#endif
112-

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionAsset.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public string ToJson()
301301
{
302302
return JsonUtility.ToJson(new WriteFileJson
303303
{
304-
version = m_Version,
304+
version = (m_Version >= 13) ? (int?)m_Version : null,
305305
name = name,
306306
maps = InputActionMap.WriteFileJson.FromMaps(m_ActionMaps).maps,
307307
controlSchemes = InputControlScheme.SchemeJson.ToJson(m_ControlSchemes),
@@ -961,7 +961,7 @@ private void OnDestroy()
961961
[Serializable]
962962
internal struct WriteFileJson
963963
{
964-
public int version;
964+
public int? version;
965965
public string name;
966966
public InputActionMap.WriteMapJson[] maps;
967967
public InputControlScheme.SchemeJson[] controlSchemes;

0 commit comments

Comments
 (0)