Class InputParameterEditor<TObject>
A custom UI for editing parameter values on a InputProcessor, InputBindingComposite, or IInputInteraction.
Inherited Members
Namespace: UnityEngine.InputSystem.Editor
Assembly: Unity.InputSystem.dll
Syntax
public abstract class InputParameterEditor<TObject> : InputParameterEditor where TObject : class
Type Parameters
Name | Description |
---|---|
TObject |
Remarks
Custom parameter editors do not need to be registered explicitly. Say you have a custom
InputProcessor called QuantizeProcessor
. To define a custom editor
UI for it, simply define a new class based on InputParameterEditor<QuantizeProcessor>
.
public class QuantizeProcessorEditor : InputParameterEditor<QuantizeProcessor>
{
// You can put initialization logic in OnEnable, if you need it.
public override void OnEnable()
{
// Use the 'target' property to access the QuantizeProcessor instance.
}
// In OnGUI, you can define custom UI elements. Use EditorGUILayout to lay
// out the controls.
public override void OnGUI()
{
// Say that QuantizeProcessor has a "stepping" property that determines
// the stepping distance for discrete values returned by the processor.
// We can expose it here as a float field. To apply the modification to
// processor object, we just assign the value back to the field on it.
target.stepping = EditorGUILayout.FloatField(
m_SteppingLabel, target.stepping);
}
private GUIContent m_SteppingLabel = new GUIContent("Stepping",
"Discrete stepping with which input values will be quantized.");
}
Note that a parameter editor takes over the entire editing UI for the object and not just the editing of specific parameters.
The default parameter editor will derive names from the names of the respective
fields just like the Unity inspector does. Also, it will respect tooltips applied
to these fields with Unity's TooltipAttribute
.
So, let's say that QuantizeProcessor
from our example was defined like
below. In that case, the result would be equivalent to the custom parameter editor
UI defined above.
public class QuantizeProcessor : InputProcessor<float>
{
[Tooltip("Discrete stepping with which input values will be quantized.")]
public float stepping;
public override float Process(float value, InputControl control)
{
return value - value % stepping;
}
}
Properties
target
The InputProcessor, InputBindingComposite, or IInputInteraction being edited.
Declaration
public TObject target { get; }
Property Value
Type | Description |
---|---|
TObject |
Methods
OnDrawVisualElements(VisualElement, Action)
Default stub implementation of OnDrawVisualElements(VisualElement, Action). Should be overridden to create the desired UI.
Declaration
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | root | |
Action | onChangedCallback |
Overrides
OnEnable()
Called after the parameter editor has been initialized.
Declaration
protected virtual void OnEnable()