Skip to content

Commit 2eefe5a

Browse files
committed
Fixed example that would not compile.
1 parent b352085 commit 2eefe5a

File tree

1 file changed

+71
-54
lines changed

1 file changed

+71
-54
lines changed

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

Lines changed: 71 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,53 +1816,53 @@ internal int BindingIndexOnMapToBindingIndexOnAction(int indexOfBindingOnMap)
18161816
///
18171817
/// <example>
18181818
/// <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-
/// }
1819+
/// using UnityEngine;
1820+
/// using UnityEngine.InputSystem;
1821+
/// using UnityEngine.InputSystem.Interactions;
1822+
///
1823+
/// public class MyController : MonoBehaviour
1824+
/// {
1825+
/// [SerializeField] InputActionReference move;
1826+
/// [SerializeField] InputActionReference fire;
1827+
///
1828+
/// void Awake()
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.action?.Enable();
1839+
/// move.action?.Enable();
1840+
/// }
1841+
///
1842+
/// void OnDisable()
1843+
/// {
1844+
/// /// Disable actions as part of disabling this behavior.
1845+
/// move.action?.Disable();
1846+
/// move.action?.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<Vector2>();
1853+
/// Debug.Log("Move: " + direction * Time.deltaTime);
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+
/// Debug.Log("Fire charged projectile");
1862+
/// else
1863+
/// Debug.Log("Fire projectile");
1864+
/// }
1865+
/// }
18661866
/// </code>
18671867
/// </example>
18681868
/// </remarks>
@@ -1954,14 +1954,31 @@ public unsafe InputActionPhase phase
19541954
/// <remarks>
19551955
/// <example>
19561956
/// <code>
1957-
/// void FirePerformed(InputAction.CallbackContext context)
1957+
/// using UnityEngine;
1958+
/// using UnityEngine.InputSystem;
1959+
/// using UnityEngine.InputSystem.Interactions;
1960+
///
1961+
/// class Example : MonoBehaviour
19581962
/// {
1959-
/// // If SlowTap interaction was performed, perform a charged
1960-
/// // firing. Otherwise, fire normally.
1961-
/// if (context.interaction is SlowTapInteraction)
1962-
/// FireChargedProjectile();
1963-
/// else
1964-
/// FireNormalProjectile();
1963+
/// public InputActionReference fire;
1964+
///
1965+
/// public void Awake()
1966+
/// {
1967+
/// fire.action.performed += FirePerformed;
1968+
/// }
1969+
///
1970+
/// void OnEnable() => fire.action.Enable();
1971+
/// void OnDisable() => fire.action.Disable();
1972+
///
1973+
/// void FirePerformed(InputAction.CallbackContext context)
1974+
/// {
1975+
/// /// If SlowTap interaction was performed, perform a charged
1976+
/// /// firing. Otherwise, fire normally.
1977+
/// if (context.interaction is SlowTapInteraction)
1978+
/// Debug.Log("Fire charged projectile");
1979+
/// else
1980+
/// Debug.Log("Fire projectile");
1981+
/// }
19651982
/// }
19661983
/// </code>
19671984
/// </example>

0 commit comments

Comments
 (0)