Skip to content

Commit 208f8dd

Browse files
committed
FIX: Added struct example and extended remarks section in xml docs.
1 parent 59c7c40 commit 208f8dd

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,80 @@ internal int BindingIndexOnMapToBindingIndexOnAction(int indexOfBindingOnMap)
17911791
/// Information provided to action callbacks about what triggered an action.
17921792
/// </summary>
17931793
/// <remarks>
1794+
/// The callback context represents the current state of an <see cref="action"/> associated with the callback
1795+
/// and provides information associated with the bound <see cref="control"/>, its value as well as its
1796+
/// <see cref="phase"/>.
1797+
///
1798+
/// The callback context provides means to consume events (push-based input) as part of an update when using
1799+
/// input action callback notifications, e.g. <see cref="InputAction.started"/>,
1800+
/// <see cref="InputAction.performed"/>, <see cref="InputAction.canceled"/> rather than relying on
1801+
/// pull-based reading.
1802+
///
1803+
/// Use this struct to read the current input value through any of the read-method overloads:
1804+
/// <see cref="ReadValue{T}()"/>, <see cref="ReadValueAsButton"/>,
1805+
/// <see cref="ReadValueAsObject()"/> or <see cref="ReadValue" /> (unsafe). If the expected value type is not
1806+
/// known, it maye be required to check <see cref="valueType"/> before reading the value.
1807+
///
1808+
/// Use the <see cref="phase"/> property to get the current phase of the associated action or
1809+
/// evaluate it directly via any of the convenience methods <see cref="started"/>, <see cref="performed"/>,
1810+
/// <see cref="canceled"/>.
1811+
///
1812+
/// To obtain information about the current timestamp of the associated event or reason about for how
1813+
/// long the action have been performing use <see cref="time"/> or <see cref="startTime"/> respectively.
1814+
///
17941815
/// This struct should not be held on to past the duration of the callback.
1816+
///
1817+
/// <example>
1818+
/// <code>
1819+
/// public class MyController : MonoBehavior
1820+
/// {
1821+
/// [SerializeFiled] Character target;
1822+
/// [SerializeField] InputActionReference move;
1823+
/// [SerializeField] InputActionReference fire;
1824+
///
1825+
/// void Awake()
1826+
/// {
1827+
/// // Get reference to an associated character behavior
1828+
/// character = GetComponent&lt;Character&gt;();
1829+
///
1830+
/// // Receive notifications when move or fire actions are performed
1831+
/// move.action.performed += MovePerformed;
1832+
/// fire.action.performed += FirePerformed;
1833+
/// }
1834+
///
1835+
/// void OnEnable()
1836+
/// {
1837+
/// // Enable actions as part of enabling this behavior.
1838+
/// move.Enable();
1839+
/// fire.Enable();
1840+
/// }
1841+
///
1842+
/// void OnDisable()
1843+
/// {
1844+
/// // Disable actions as part of disabling this behavior.
1845+
/// move.Disable();
1846+
/// fire.Disable();
1847+
/// }
1848+
///
1849+
/// void MovePerformed(InputAction.CallbackContext context)
1850+
/// {
1851+
/// // Read the current 2D vector value reported by the associated input action.
1852+
/// var direction = context.ReadValue&lt;Vector2&gt;();
1853+
/// target.Move( direction );
1854+
/// }
1855+
///
1856+
/// void FirePerformed(InputAction.CallbackContext context)
1857+
/// {
1858+
/// // If underlying interaction is a slow-tap fire charged projectile, otherwise fire regular
1859+
/// // projectile.
1860+
/// if (context.interaction is SlowTapInteraction)
1861+
/// target.FireChargedProjectile();
1862+
/// else
1863+
/// target.FireProjectile();
1864+
/// }
1865+
/// }
1866+
/// </code>
1867+
/// </example>
17951868
/// </remarks>
17961869
/// <seealso cref="performed"/>
17971870
/// <seealso cref="started"/>

0 commit comments

Comments
 (0)