-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
91 changed files
with
2,660 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "ProjectWideActionsTest", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:75469ad4d38634e559750d17036d5f7c" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [ | ||
{ | ||
"name": "Unity", | ||
"expression": "2022.3", | ||
"define": "UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS" | ||
} | ||
], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS | ||
|
||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
|
||
public class NewBehaviourScript : MonoBehaviour | ||
{ | ||
[SerializeField] public GameObject cube; | ||
|
||
InputAction move; | ||
InputAction look; | ||
InputAction attack; | ||
InputAction jump; | ||
InputAction interact; | ||
InputAction next; | ||
InputAction previous; | ||
InputAction sprint; | ||
InputAction crouch; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
// Project-Wide Actions | ||
move = InputSystem.actions.FindAction("Player/Move"); | ||
look = InputSystem.actions.FindAction("Player/Look"); | ||
attack = InputSystem.actions.FindAction("Player/Attack"); | ||
jump = InputSystem.actions.FindAction("Player/Jump"); | ||
interact = InputSystem.actions.FindAction("Player/Interact"); | ||
next = InputSystem.actions.FindAction("Player/Next"); | ||
previous = InputSystem.actions.FindAction("Player/Previous"); | ||
sprint = InputSystem.actions.FindAction("Player/Sprint"); | ||
crouch = InputSystem.actions.FindAction("Player/Crouch"); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if (attack.WasPressedThisFrame()) | ||
{ | ||
cube.GetComponent<Renderer>().material.color = Color.red; | ||
} | ||
else if (attack.WasReleasedThisFrame()) | ||
{ | ||
cube.GetComponent<Renderer>().material.color = Color.green; | ||
} | ||
|
||
var moveVal = move.ReadValue<Vector2>(); | ||
if (moveVal.x < 0.0f) | ||
{ | ||
cube.transform.Translate(new Vector3(-10 * Time.deltaTime, 0, 0)); | ||
} | ||
else if (moveVal.x > 0.0f) | ||
{ | ||
cube.transform.Translate(new Vector3(10 * Time.deltaTime, 0, 0)); | ||
} | ||
if (moveVal.y < 0.0f) | ||
{ | ||
cube.transform.Translate(new Vector3(0, -10 * Time.deltaTime, 0)); | ||
} | ||
else if (moveVal.y > 0.0f) | ||
{ | ||
cube.transform.Translate(new Vector3(0, 10 * Time.deltaTime, 0)); | ||
} | ||
} | ||
} | ||
#endif |
11 changes: 11 additions & 0 deletions
11
Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.