-
Notifications
You must be signed in to change notification settings - Fork 333
NEW: Input consumption - Priorities instead of complexity [ISX-2510] #2402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
28640eb
1eef02c
d4c1f3f
675afce
3ea57de
fb68220
423c64e
cc7adfe
9cb60d1
fa1afac
51df2ef
ec0683b
c97af36
762e1ed
7237d8e
eddb699
b7d5a5d
29aaa21
86d55b1
7836085
ca4c908
707433a
8484453
6640bde
18a234c
808decb
4c06cc6
0f167e4
7cb004e
05aed76
848b486
22d5cf7
64d3aed
5898640
916ff0e
c192365
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ public class ProjectWideActionsExample : MonoBehaviour | |
| InputAction previous; | ||
| InputAction sprint; | ||
| InputAction crouch; | ||
| InputAction b; | ||
| InputAction shiftB; | ||
|
|
||
| // Start is called before the first frame update | ||
| void Start() | ||
|
|
@@ -29,6 +31,8 @@ void Start() | |
| previous = InputSystem.actions.FindAction("Player/Previous"); | ||
| sprint = InputSystem.actions.FindAction("Player/Sprint"); | ||
| crouch = InputSystem.actions.FindAction("Player/Crouch"); | ||
| b = InputSystem.actions.FindAction("Player/B"); | ||
| shiftB = InputSystem.actions.FindAction("Player/Shift B"); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -41,6 +45,18 @@ void Start() | |
| attack.performed += OnAttack; | ||
| attack.canceled += OnCancel; | ||
| } | ||
|
|
||
| if (b != null) | ||
| { | ||
| b.performed += OnB; | ||
| b.canceled += OnCancel; | ||
| } | ||
|
|
||
| if (shiftB != null) | ||
| { | ||
| shiftB.performed += OnShiftB; | ||
| shiftB.canceled += OnCancel; | ||
| } | ||
| } | ||
|
|
||
| private void OnAttack(InputAction.CallbackContext ctx) | ||
|
|
@@ -53,13 +69,35 @@ private void OnCancel(InputAction.CallbackContext ctx) | |
| cube.GetComponent<Renderer>().material.color = Color.green; | ||
| } | ||
|
|
||
| private void OnB(InputAction.CallbackContext ctx) | ||
| { | ||
| Debug.Log("B WAS PRESSED"); | ||
| cube.GetComponent<Renderer>().material.color = Color.yellow; | ||
| } | ||
|
|
||
| private void OnShiftB(InputAction.CallbackContext ctx) | ||
| { | ||
| Debug.Log("SHIFT + B WAS PRESSED"); | ||
| cube.GetComponent<Renderer>().material.color = Color.blue; | ||
| } | ||
|
|
||
| void OnDestroy() | ||
| { | ||
| if (attack != null) | ||
| { | ||
| attack.performed -= OnAttack; | ||
| attack.canceled -= OnCancel; | ||
| } | ||
| if (b != null) | ||
| { | ||
| b.performed -= OnB; | ||
| b.canceled -= OnCancel; | ||
| } | ||
| if (shiftB != null) | ||
| { | ||
| shiftB.performed -= OnShiftB; | ||
| shiftB.canceled -= OnCancel; | ||
| } | ||
| } | ||
|
|
||
| // Update is called once per frame | ||
|
|
@@ -71,6 +109,16 @@ void Update() | |
| var moveVal = move.ReadValue<Vector2>() * 10.0f * Time.deltaTime; | ||
| cube.transform.Translate(new Vector3(moveVal.x, moveVal.y, 0)); | ||
| } | ||
|
|
||
| if (shiftB.IsPressed()) | ||
| { | ||
| Debug.Log("SHIFT + B WAS PRESSED"); | ||
| } | ||
|
|
||
| if (b.IsPressed()) | ||
| { | ||
| Debug.Log("B WAS PRESSED"); | ||
| } | ||
|
Comment on lines
+113
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Additionally, polling 🤖 Helpful? 👍/👎 |
||
| } | ||
| } // class ProjectWideActionsExample | ||
| } // namespace UnityEngine.InputSystem.Samples.ProjectWideActions | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably not ship this code. If we want a dedicated sample - we should deliver something like my visual test project. If we don't - then this code is purely for debugging and we're better off removing it for now. What do you think?