Skip to content

Commit 00590b6

Browse files
CHANGE: Revert: Deprecate useIMGUIEditorForAssets #2283 (#2347)
1 parent d1489a6 commit 00590b6

File tree

19 files changed

+198
-43
lines changed

19 files changed

+198
-43
lines changed

Assets/Samples/CustomComposite/CustomComposite.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ public class CustomCompositeEditor : InputParameterEditor<CustomComposite>
136136
{
137137
public override void OnGUI()
138138
{
139+
// Using the 'target' property, we can access an instance of our composite.
140+
var currentValue = target.scaleFactor;
141+
142+
// The easiest way to lay out our UI is to simply use EditorGUILayout.
143+
// We simply assign the changed value back to the 'target' object. The input
144+
// system will automatically detect a change in value.
145+
target.scaleFactor = EditorGUILayout.Slider(m_ScaleFactorLabel, currentValue, 0, 2);
139146
}
140147

141148
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ partial class CoreTests
3535
[TestCase(InputFeatureNames.kParanoidReadValueCachingChecks)]
3636
[TestCase(InputFeatureNames.kDisableUnityRemoteSupport)]
3737
[TestCase(InputFeatureNames.kRunPlayerUpdatesInEditMode)]
38+
[TestCase(InputFeatureNames.kUseIMGUIEditorForAssets)]
3839
public void Settings_ShouldStoreSettingsAndFeatureFlags(string featureName)
3940
{
4041
using (var settings = Scoped.Object(InputSettings.CreateInstance<InputSettings>()))

Assets/Tests/InputSystem/CoreTests_Analytics.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public void Analytics_ShouldReportBuildAnalytics_WhenNotHavingSettingsAsset()
458458
Assert.That(data.feature_paranoid_read_value_caching_checks_enabled, Is.EqualTo(defaultSettings.IsFeatureEnabled(InputFeatureNames.kParanoidReadValueCachingChecks)));
459459
Assert.That(data.feature_disable_unity_remote_support, Is.EqualTo(defaultSettings.IsFeatureEnabled(InputFeatureNames.kDisableUnityRemoteSupport)));
460460
Assert.That(data.feature_run_player_updates_in_editmode, Is.EqualTo(defaultSettings.IsFeatureEnabled(InputFeatureNames.kRunPlayerUpdatesInEditMode)));
461+
Assert.That(data.feature_use_imgui_editor_for_assets, Is.EqualTo(defaultSettings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)));
461462
}
462463
finally
463464
{
@@ -506,6 +507,7 @@ public void Analytics_ShouldReportBuildAnalytics_WhenHavingSettingsAssetWithCust
506507
customSettings.SetInternalFeatureFlag(InputFeatureNames.kParanoidReadValueCachingChecks, true);
507508
customSettings.SetInternalFeatureFlag(InputFeatureNames.kDisableUnityRemoteSupport, true);
508509
customSettings.SetInternalFeatureFlag(InputFeatureNames.kRunPlayerUpdatesInEditMode, true);
510+
customSettings.SetInternalFeatureFlag(InputFeatureNames.kUseIMGUIEditorForAssets, true);
509511
customSettings.SetInternalFeatureFlag(InputFeatureNames.kUseReadValueCaching, true);
510512

511513
InputSystem.settings = customSettings;
@@ -552,6 +554,7 @@ public void Analytics_ShouldReportBuildAnalytics_WhenHavingSettingsAssetWithCust
552554
Assert.That(data.feature_paranoid_read_value_caching_checks_enabled, Is.True);
553555
Assert.That(data.feature_disable_unity_remote_support, Is.True);
554556
Assert.That(data.feature_run_player_updates_in_editmode, Is.True);
557+
Assert.That(data.feature_use_imgui_editor_for_assets, Is.True);
555558
}
556559
finally
557560
{

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ however, it has to be formatted properly to pass verification tests.
1212

1313
### Changed
1414

15+
- Reverted the deprecation of the USE_IMGUI_EDITOR_FOR_ASSETS feature option (ISX-2397).
1516
- Updated `m_ActionAssetInstanceID` in PlayerInputEditor.cs to use `EntityId` instead of `InstanceID`.
1617
- Consecutive wildcard characters ('*') used in input control-paths are now collapsed into a single wildcard when multiple consecutive wildcard characters are present.
1718

Packages/com.unity.inputsystem/InputSystem/Actions/Composites/AxisComposite.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#if UNITY_EDITOR
77
using System;
8+
using UnityEditor;
89
using UnityEngine.InputSystem.Editor;
910
using UnityEngine.UIElements;
1011
#endif
@@ -211,20 +212,24 @@ public enum WhichSideWins
211212
#if UNITY_EDITOR
212213
internal class AxisCompositeEditor : InputParameterEditor<AxisComposite>
213214
{
214-
private const string label = "Which Side Wins";
215-
private const string tooltipText = "Determine which axis 'wins' if both are actuated at the same time. "
215+
private GUIContent m_WhichAxisWinsLabel = new GUIContent("Which Side Wins",
216+
"Determine which axis 'wins' if both are actuated at the same time. "
216217
+ "If 'Neither' is selected, the result is 0 (or, more precisely, "
217-
+ "the midpoint between minValue and maxValue).";
218+
+ "the midpoint between minValue and maxValue).");
218219

219220
public override void OnGUI()
220221
{
222+
if (!InputSystem.settings.useIMGUIEditorForAssets)
223+
return;
224+
225+
target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins);
221226
}
222227

223228
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
224229
{
225-
var modeField = new EnumField(label, target.whichSideWins)
230+
var modeField = new EnumField(m_WhichAxisWinsLabel.text, target.whichSideWins)
226231
{
227-
tooltip = tooltipText
232+
tooltip = m_WhichAxisWinsLabel.tooltip
228233
};
229234

230235
modeField.RegisterValueChangedCallback(evt =>

Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine.InputSystem.Utilities;
66

77
#if UNITY_EDITOR
8+
using UnityEditor;
89
using UnityEngine.InputSystem.Editor;
910
using UnityEngine.UIElements;
1011
#endif
@@ -191,20 +192,24 @@ public enum Mode
191192
#if UNITY_EDITOR
192193
internal class Vector2CompositeEditor : InputParameterEditor<Vector2Composite>
193194
{
194-
private const string label = "Mode";
195-
private const string tooltipText = "How to synthesize a Vector2 from the inputs. Digital "
195+
private GUIContent m_ModeLabel = new GUIContent("Mode",
196+
"How to synthesize a Vector2 from the inputs. Digital "
196197
+ "treats part bindings as buttons (on/off) whereas Analog preserves "
197-
+ "floating-point magnitudes as read from controls.";
198+
+ "floating-point magnitudes as read from controls.");
198199

199200
public override void OnGUI()
200201
{
202+
if (!InputSystem.settings.useIMGUIEditorForAssets)
203+
return;
204+
205+
target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
201206
}
202207

203208
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
204209
{
205-
var modeField = new EnumField(label, target.mode)
210+
var modeField = new EnumField(m_ModeLabel.text, target.mode)
206211
{
207-
tooltip = tooltipText
212+
tooltip = m_ModeLabel.tooltip
208213
};
209214

210215
modeField.RegisterValueChangedCallback(evt =>

Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector3Composite.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine.InputSystem.Utilities;
55

66
#if UNITY_EDITOR
7+
using UnityEditor;
78
using UnityEngine.InputSystem.Editor;
89
using UnityEngine.UIElements;
910
#endif
@@ -171,20 +172,24 @@ public enum Mode
171172
#if UNITY_EDITOR
172173
internal class Vector3CompositeEditor : InputParameterEditor<Vector3Composite>
173174
{
174-
private const string label = "Mode";
175-
private const string tooltip = "How to synthesize a Vector3 from the inputs. Digital "
175+
private GUIContent m_ModeLabel = new GUIContent("Mode",
176+
"How to synthesize a Vector3 from the inputs. Digital "
176177
+ "treats part bindings as buttons (on/off) whereas Analog preserves "
177-
+ "floating-point magnitudes as read from controls.";
178+
+ "floating-point magnitudes as read from controls.");
178179

179180
public override void OnGUI()
180181
{
182+
if (!InputSystem.settings.useIMGUIEditorForAssets)
183+
return;
184+
185+
target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
181186
}
182187

183188
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
184189
{
185-
var modeField = new EnumField(label, target.mode)
190+
var modeField = new EnumField(m_ModeLabel.text, target.mode)
186191
{
187-
tooltip = tooltip
192+
tooltip = m_ModeLabel.tooltip
188193
};
189194

190195
modeField.RegisterValueChangedCallback(evt =>

Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/HoldInteraction.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.ComponentModel;
33
using UnityEngine.InputSystem.Controls;
4-
4+
using UnityEngine.Scripting;
55
#if UNITY_EDITOR
66
using UnityEngine.InputSystem.Editor;
77
using UnityEngine.UIElements;
@@ -124,6 +124,11 @@ protected override void OnEnable()
124124

125125
public override void OnGUI()
126126
{
127+
if (!InputSystem.settings.useIMGUIEditorForAssets)
128+
return;
129+
130+
m_PressPointSetting.OnGUI();
131+
m_DurationSetting.OnGUI();
127132
}
128133

129134
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)

Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/MultiTapInteraction.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using UnityEngine.InputSystem.Controls;
3-
3+
using UnityEngine.Scripting;
44
#if UNITY_EDITOR
5+
using UnityEditor;
56
using UnityEngine.InputSystem.Editor;
67
using UnityEngine.UIElements;
8+
using UnityEditor.UIElements;
79
#endif
810

911
////TODO: add ability to respond to any of the taps in the sequence (e.g. one response for single tap, another for double tap)
@@ -194,14 +196,21 @@ protected override void OnEnable()
194196

195197
public override void OnGUI()
196198
{
199+
if (!InputSystem.settings.useIMGUIEditorForAssets)
200+
return;
201+
202+
target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount);
203+
m_TapDelaySetting.OnGUI();
204+
m_TapTimeSetting.OnGUI();
205+
m_PressPointSetting.OnGUI();
197206
}
198207

199208
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
200209
{
201-
var tapCountField = new IntegerField(tapLabel)
210+
var tapCountField = new IntegerField(m_TapCountLabel.text)
202211
{
203212
value = target.tapCount,
204-
tooltip = tapTooltip
213+
tooltip = m_TapCountLabel.tooltip
205214
};
206215
tapCountField.RegisterValueChangedCallback(evt =>
207216
{
@@ -215,8 +224,7 @@ public override void OnDrawVisualElements(VisualElement root, Action onChangedCa
215224
m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback);
216225
}
217226

218-
private const string tapLabel = "Tap Count";
219-
private const string tapTooltip = "How many taps need to be performed in succession. Two means double-tap, three means triple-tap, and so on.";
227+
private readonly GUIContent m_TapCountLabel = new GUIContent("Tap Count", "How many taps need to be performed in succession. Two means double-tap, three means triple-tap, and so on.");
220228

221229
private CustomOrDefaultSetting m_PressPointSetting;
222230
private CustomOrDefaultSetting m_TapTimeSetting;

Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/PressInteraction.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System;
22
using System.ComponentModel;
33
using UnityEngine.InputSystem.Controls;
4+
using UnityEngine.Scripting;
45
#if UNITY_EDITOR
6+
using UnityEditor;
57
using UnityEngine.InputSystem.Editor;
68
using UnityEngine.UIElements;
9+
using UnityEditor.UIElements;
710
#endif
811

912
////TODO: protect against the control *hovering* around the press point; this should not fire the press repeatedly; probably need a zone around the press point
@@ -210,15 +213,21 @@ protected override void OnEnable()
210213

211214
public override void OnGUI()
212215
{
216+
if (!InputSystem.settings.useIMGUIEditorForAssets)
217+
return;
218+
219+
EditorGUILayout.HelpBox(s_HelpBoxText);
220+
target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior);
221+
m_PressPointSetting.OnGUI();
213222
}
214223

215224
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
216225
{
217-
root.Add(new HelpBox(helpLabel, HelpBoxMessageType.None));
226+
root.Add(new HelpBox(s_HelpBoxText.text, HelpBoxMessageType.None));
218227

219-
var behaviourDropdown = new EnumField(triggerLabel, target.behavior)
228+
var behaviourDropdown = new EnumField(s_PressBehaviorLabel.text, target.behavior)
220229
{
221-
tooltip = triggerTooltip
230+
tooltip = s_PressBehaviorLabel.tooltip
222231
};
223232
behaviourDropdown.RegisterValueChangedCallback(evt =>
224233
{
@@ -232,13 +241,14 @@ public override void OnDrawVisualElements(VisualElement root, Action onChangedCa
232241

233242
private CustomOrDefaultSetting m_PressPointSetting;
234243

235-
private const string helpLabel = "Note that the 'Press' interaction is only "
244+
private static readonly GUIContent s_HelpBoxText = EditorGUIUtility.TrTextContent("Note that the 'Press' interaction is only "
236245
+ "necessary when wanting to customize button press behavior. For default press behavior, simply set the action type to 'Button' "
237-
+ "and use the action without interactions added to it.";
238-
private const string triggerLabel = "Trigger Behavior";
239-
private const string triggerTooltip = "Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. "
246+
+ "and use the action without interactions added to it.");
247+
248+
private static readonly GUIContent s_PressBehaviorLabel = EditorGUIUtility.TrTextContent("Trigger Behavior",
249+
"Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. "
240250
+ "With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and "
241-
+ "canceled on release.";
251+
+ "canceled on release.");
242252
}
243253
#endif
244254
}

0 commit comments

Comments
 (0)