From 9bf6802fd68870b53f72c9662134799f1bbe5e53 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Tue, 3 Dec 2024 21:10:42 +0100 Subject: [PATCH 1/3] API doc update --- .../InputSystem/Controls/ButtonControl.cs | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs index fe28ffe352..4b6c03887a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs @@ -10,7 +10,7 @@ namespace UnityEngine.InputSystem.Controls /// An axis that has a trigger point beyond which it is considered to be pressed. /// /// - /// By default stored as a single bit. In that format, buttons will only yield 0 + /// By default, stored as a single bit. In that format, buttons will only yield 0 /// and 1 as values. However, buttons return are s and /// yield full floating-point values and may thus have a range of values. See /// for how button presses on such buttons are handled. @@ -46,6 +46,9 @@ public class ButtonControl : AxisControl /// /// /// + /// using UnityEngine; + /// using UnityEngine.InputSystem.Controls; + /// /// public class MyDevice : InputDevice /// { /// [InputControl(parameters = "pressPoint=0.234")] @@ -56,25 +59,38 @@ public class ButtonControl : AxisControl /// /// /// - /// - /// - /// public float pressPoint = -1; /// /// Return if set, otherwise return . /// /// Effective value to use for press point thresholds. - /// public float pressPointOrDefault => pressPoint > 0 ? pressPoint : s_GlobalDefaultButtonPressPoint; /// - /// Default-initialize the control. + /// Default-initialize the button control. /// /// - /// The default format for the control is . - /// The control's minimum value is set to 0 and the maximum value to 1. + /// The default format for the button control is . + /// The button control's minimum value is set to 0 and the maximum value to 1. + /// + /// + /// using UnityEngine; + /// using UnityEngine.InputSystem.Controls; + /// + /// public class ButtonControlExample : MonoBehaviour + /// { + /// void Start() + /// { + /// var myButton = new ButtonControl(); + /// } + /// + /// //... + /// } + /// + /// /// + /// public ButtonControl() { m_StateBlock.format = InputStateBlock.FormatBit; @@ -85,10 +101,39 @@ public ButtonControl() /// /// Whether the given value would be considered pressed for this button. /// - /// Value for the button. + /// Value to check for if the button would be considered pressed or not. /// True if crosses the threshold to be considered pressed. - /// - /// + /// + /// The default format for the control is . + /// The control's minimum value is set to 0 and the maximum value to 1. + /// See for the default press point. + /// + /// + /// using UnityEngine; + /// using UnityEngine.InputSystem.Controls; + /// + /// public class IsValueConsideredPressedExample : MonoBehaviour + /// { + /// void Start() + /// { + /// var myButton = new ButtonControl(); + /// var valueToTest = 0.5f; + /// + /// if (myButton.IsValueConsideredPressed(valueToTest)) + /// { + /// Debug.Log("myButton is considered pressed at: " + valueToTest.ToString()); + /// } + /// else + /// { + /// Debug.Log("myButton is not considered pressed at: " + valueToTest.ToString()); + /// } + /// } + /// + /// //... + /// } + /// + /// + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public new bool IsValueConsideredPressed(float value) { @@ -149,9 +194,6 @@ public ButtonControl() /// ]]> /// /// - /// - /// - /// public bool isPressed { get From ce2ea7bf7d23a7318ff641323f8ddb0f7d9b46f5 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Dec 2024 09:25:48 +0100 Subject: [PATCH 2/3] fix docs error --- .../InputSystem/Controls/ButtonControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs index 4b6c03887a..ae541310ca 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs @@ -107,6 +107,7 @@ public ButtonControl() /// The default format for the control is . /// The control's minimum value is set to 0 and the maximum value to 1. /// See for the default press point. + /// /// /// /// using UnityEngine; @@ -133,7 +134,6 @@ public ButtonControl() /// } /// /// - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public new bool IsValueConsideredPressed(float value) { @@ -318,8 +318,8 @@ public bool wasPressedThisFrame /// { /// void Update() /// { - /// bool buttonPressed = Gamepad.current.aButton.wasReleasedThisFrame; - /// bool spaceKeyPressed = Keyboard.current.spaceKey.wasReleasedThisFrame; + /// bool buttonReleased = Gamepad.current.aButton.wasReleasedThisFrame; + /// bool spaceKeyReleased = Keyboard.current.spaceKey.wasReleasedThisFrame; /// } /// } /// From e109c57f26088f8176256231877bbff04d7622ca Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Dec 2024 10:14:29 +0100 Subject: [PATCH 3/3] one more doc error fix --- .../com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs index ae541310ca..ec35ca059e 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs @@ -73,6 +73,7 @@ public class ButtonControl : AxisControl /// /// The default format for the button control is . /// The button control's minimum value is set to 0 and the maximum value to 1. + /// /// /// /// using UnityEngine; @@ -89,7 +90,6 @@ public class ButtonControl : AxisControl /// } /// /// - /// /// public ButtonControl() {