Skip to content
Draft
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
7 changes: 7 additions & 0 deletions Assets/Samples/CustomComposite/CustomComposite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ public class CustomCompositeEditor : InputParameterEditor<CustomComposite>
{
public override void OnGUI()
{
// Using the 'target' property, we can access an instance of our composite.
var currentValue = target.scaleFactor;

// The easiest way to lay out our UI is to simply use EditorGUILayout.
// We simply assign the changed value back to the 'target' object. The input
// system will automatically detect a change in value.
target.scaleFactor = EditorGUILayout.Slider(m_ScaleFactorLabel, currentValue, 0, 2);
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
#endif
Expand Down Expand Up @@ -211,20 +212,24 @@ public enum WhichSideWins
#if UNITY_EDITOR
internal class AxisCompositeEditor : InputParameterEditor<AxisComposite>
{
private const string label = "Which Side Wins";
private const string tooltipText = "Determine which axis 'wins' if both are actuated at the same time. "
private GUIContent m_WhichAxisWinsLabel = new GUIContent("Which Side Wins",
"Determine which axis 'wins' if both are actuated at the same time. "
+ "If 'Neither' is selected, the result is 0 (or, more precisely, "
+ "the midpoint between minValue and maxValue).";
+ "the midpoint between minValue and maxValue).");

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins);
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var modeField = new EnumField(label, target.whichSideWins)
var modeField = new EnumField(m_WhichAxisWinsLabel.text, target.whichSideWins)
{
tooltip = tooltipText
tooltip = m_WhichAxisWinsLabel.tooltip
};

modeField.RegisterValueChangedCallback(evt =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using UnityEngine.InputSystem.Utilities;

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
#endif
Expand Down Expand Up @@ -191,20 +192,24 @@ public enum Mode
#if UNITY_EDITOR
internal class Vector2CompositeEditor : InputParameterEditor<Vector2Composite>
{
private const string label = "Mode";
private const string tooltipText = "How to synthesize a Vector2 from the inputs. Digital "
private GUIContent m_ModeLabel = new GUIContent("Mode",
"How to synthesize a Vector2 from the inputs. Digital "
+ "treats part bindings as buttons (on/off) whereas Analog preserves "
+ "floating-point magnitudes as read from controls.";
+ "floating-point magnitudes as read from controls.");

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var modeField = new EnumField(label, target.mode)
var modeField = new EnumField(m_ModeLabel.text, target.mode)
{
tooltip = tooltipText
tooltip = m_ModeLabel.tooltip
};

modeField.RegisterValueChangedCallback(evt =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEngine.InputSystem.Utilities;

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
#endif
Expand Down Expand Up @@ -171,20 +172,24 @@ public enum Mode
#if UNITY_EDITOR
internal class Vector3CompositeEditor : InputParameterEditor<Vector3Composite>
{
private const string label = "Mode";
private const string tooltip = "How to synthesize a Vector3 from the inputs. Digital "
private GUIContent m_ModeLabel = new GUIContent("Mode",
"How to synthesize a Vector3 from the inputs. Digital "
+ "treats part bindings as buttons (on/off) whereas Analog preserves "
+ "floating-point magnitudes as read from controls.";
+ "floating-point magnitudes as read from controls.");

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var modeField = new EnumField(label, target.mode)
var modeField = new EnumField(m_ModeLabel.text, target.mode)
{
tooltip = tooltip
tooltip = m_ModeLabel.tooltip
};

modeField.RegisterValueChangedCallback(evt =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel;
using UnityEngine.InputSystem.Controls;

using UnityEngine.Scripting;
#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -124,6 +124,11 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

m_PressPointSetting.OnGUI();
m_DurationSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using UnityEngine.InputSystem.Controls;

using UnityEngine.Scripting;
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
#endif

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

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount);
m_TapDelaySetting.OnGUI();
m_TapTimeSetting.OnGUI();
m_PressPointSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var tapCountField = new IntegerField(tapLabel)
var tapCountField = new IntegerField(m_TapCountLabel.text)
{
value = target.tapCount,
tooltip = tapTooltip
tooltip = m_TapCountLabel.tooltip
};
tapCountField.RegisterValueChangedCallback(evt =>
{
Expand All @@ -215,8 +224,7 @@ public override void OnDrawVisualElements(VisualElement root, Action onChangedCa
m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback);
}

private const string tapLabel = "Tap Count";
private const string tapTooltip = "How many taps need to be performed in succession. Two means double-tap, three means triple-tap, and so on.";
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.");

private CustomOrDefaultSetting m_PressPointSetting;
private CustomOrDefaultSetting m_TapTimeSetting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.ComponentModel;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Scripting;
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
#endif

////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
Expand Down Expand Up @@ -210,15 +213,21 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

EditorGUILayout.HelpBox(s_HelpBoxText);
target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior);
m_PressPointSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
root.Add(new HelpBox(helpLabel, HelpBoxMessageType.None));
root.Add(new HelpBox(s_HelpBoxText.text, HelpBoxMessageType.None));

var behaviourDropdown = new EnumField(triggerLabel, target.behavior)
var behaviourDropdown = new EnumField(s_PressBehaviorLabel.text, target.behavior)
{
tooltip = triggerTooltip
tooltip = s_PressBehaviorLabel.tooltip
};
behaviourDropdown.RegisterValueChangedCallback(evt =>
{
Expand All @@ -232,13 +241,14 @@ public override void OnDrawVisualElements(VisualElement root, Action onChangedCa

private CustomOrDefaultSetting m_PressPointSetting;

private const string helpLabel = "Note that the 'Press' interaction is only "
private static readonly GUIContent s_HelpBoxText = EditorGUIUtility.TrTextContent("Note that the 'Press' interaction is only "
+ "necessary when wanting to customize button press behavior. For default press behavior, simply set the action type to 'Button' "
+ "and use the action without interactions added to it.";
private const string triggerLabel = "Trigger Behavior";
private const string triggerTooltip = "Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. "
+ "and use the action without interactions added to it.");

private static readonly GUIContent s_PressBehaviorLabel = EditorGUIUtility.TrTextContent("Trigger Behavior",
"Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. "
+ "With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and "
+ "canceled on release.";
+ "canceled on release.");
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Scripting;
#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -87,6 +88,11 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Scripting;
#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -113,6 +114,11 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Scripting;

#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
Expand Down Expand Up @@ -92,6 +93,11 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

m_MinSetting.OnGUI();
m_MaxSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Scripting;

#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
Expand Down Expand Up @@ -81,6 +82,11 @@ protected override void OnEnable()

public override void OnGUI()
{
if (!InputSystem.settings.useIMGUIEditorForAssets)
return;

m_MinSetting.OnGUI();
m_MaxSetting.OnGUI();
}

public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,4 @@ public void OnPostprocessBuild(BuildReport report)
}
}
}
#endif
#endif
Loading
Loading