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
2
2
3
3
using System ;
4
4
using NUnit . Framework ;
@@ -29,6 +29,7 @@ static CustomProcessor()
29
29
{
30
30
Initialize ( ) ;
31
31
}
32
+
32
33
#endif
33
34
34
35
[ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
@@ -54,7 +55,7 @@ public override void OneTimeSetUp()
54
55
55
56
var actionMap = m_Asset . AddActionMap ( "Action Map" ) ;
56
57
57
- actionMap . AddAction ( "Action" , InputActionType . Value , processors : "Custom(SomeEnum=10)" ) ;
58
+ actionMap . AddAction ( "Action" , InputActionType . Value , processors : "Custom(SomeEnum=10)" ) ;
58
59
}
59
60
60
61
public override void OneTimeTearDown ( )
@@ -68,21 +69,21 @@ public override IEnumerator UnitySetup()
68
69
m_Window = InputActionsEditorWindow . OpenEditor ( m_Asset ) ;
69
70
yield return base . UnitySetup ( ) ;
70
71
}
71
-
72
+
72
73
[ UnityTest ]
73
74
public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset ( )
74
75
{
75
76
// Serialize current asset to JSON, and check that initial JSON contains default enum value for OptionA
76
77
var json = m_Window . currentAssetInEditor . ToJson ( ) ;
77
-
78
+
78
79
Assert . That ( json . Contains ( "Custom(SomeEnum=10)" ) , Is . True ,
79
80
"Serialized JSON does not contain the expected custom processor string for OptionA." ) ;
80
81
81
82
// Query the dropdown with exactly two enum choices and check that the drop down is present in the UI
82
83
var dropdownList = m_Window . rootVisualElement . Query < DropdownField > ( ) . Where ( d => d . choices . Count == 2 ) . ToList ( ) ;
83
84
Assume . That ( dropdownList . Count > 0 , Is . True , "Enum parameter dropdown not found in the UI." ) ;
84
85
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
86
87
var dropdown = dropdownList . First ( ) ;
87
88
var newValue = dropdown . choices [ 1 ] ;
88
89
dropdown . Focus ( ) ;
@@ -92,7 +93,7 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
92
93
var changeEvent = ChangeEvent < Enum > . GetPooled ( SomeEnum . OptionA , SomeEnum . OptionB ) ;
93
94
changeEvent . target = dropdown ;
94
95
dropdown . SendEvent ( changeEvent ) ;
95
-
96
+
96
97
// Find the save button in the window, focus and click the save button to persist the changes
97
98
var saveButton = m_Window . rootVisualElement . Q < Button > ( "save-asset-toolbar-button" ) ;
98
99
Assume . That ( saveButton , Is . Not . Null , "Save Asset button not found in the UI." ) ;
@@ -109,4 +110,3 @@ public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
109
110
}
110
111
}
111
112
#endif
112
-
0 commit comments