Skip to content

Commit a56878c

Browse files
jamesmcgilljfreire-unitylyndon-unityduckets
authored
NEW: Project-wide Actions (#1735)
* Add InputSystem.actions property * Add ProjectWideActions Test Sample * Rename conditonal compilation flag for project-wide actions * Ensure UITK action editor appears in Project Settings * Fix project settings editor not populating actions * Fix for dupliate editors shown * FIX: Global Actions UI flickers when user expands actions (#1738) * Fix for API validation test failure * Fix ProjectWide Actions Enable/Disable flow for tests * Prevent assertion which may happen if ProjectWide Actions are Enabled without any devices attached yet in tests * Disable ProjectWide actions in some tests that assume there are no other actions * Fixed issue with Input Actions UI becoming blank due to error (ISX-1584) * DOCF-3823 - pre release docs * Added stub doc to InputSystem.actions * Added compilation constant to enable global actions during docs generation * Fixed whitespace typo * Update PreReleaseNotes.md tidied whitespace in code sample * Updated define for documentation generation to include the project wide actions API * Hiding search field while not implemented (ISX-1582) * Updated control bindings based on latest review Next/Previous updated to be more intuative/same axis Names for UI Click* restored to original Added keyboard binding for Attack Added some XR bindings Some reordering too E.g. so crouch/jump next to each other This makes the diff slightly harder * Fix tests not compiling on older editors * Ran formatting script to fix warnings * Hiding save, auto save buttons in project wide input settings as its auto saving always atm (ISX-1556) * Fixed delete key mapping to be 'delete' rather than 'space' (ISX-1552) * Fix ActionState and StateBuffer going out of sync when entering tests * Disable ProjectWide actions in some tests that assume there are no other actions or controls * Temporarily disable some tests which have issues when ProjectWide Actions are enabled * fix formatting * Update InputSystem.cs removed duplicate comment on private member * Fix broken links * improve api docs for InputSystem.actions * add changelog entry --------- Co-authored-by: João <joao.freire@unity3d.com> Co-authored-by: Lyndon Homewood <lyndon@unity3d.com> Co-authored-by: Ben Pitt <benp@unity3d.com>
1 parent d426234 commit a56878c

76 files changed

Lines changed: 2231 additions & 123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Samples/CustomComposite/CustomComposite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public override void OnGUI()
177177
target.scaleFactor = EditorGUILayout.Slider(m_ScaleFactorLabel, currentValue, 0, 2);
178178
}
179179

180-
#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
180+
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
181181
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
182182
{
183183
var slider = new Slider(m_ScaleFactorLabel.text, 0, 2)

Assets/Samples/ProjectWideActionsTest.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "ProjectWideActionsTest",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:75469ad4d38634e559750d17036d5f7c"
6+
],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [
15+
{
16+
"name": "Unity",
17+
"expression": "2022.3",
18+
"define": "UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS"
19+
}
20+
],
21+
"noEngineReferences": false
22+
}

Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2+
3+
using UnityEngine;
4+
using UnityEngine.InputSystem;
5+
6+
public class NewBehaviourScript : MonoBehaviour
7+
{
8+
[SerializeField] public GameObject cube;
9+
10+
InputAction move;
11+
InputAction look;
12+
InputAction attack;
13+
InputAction jump;
14+
InputAction interact;
15+
InputAction next;
16+
InputAction previous;
17+
InputAction sprint;
18+
InputAction crouch;
19+
20+
// Start is called before the first frame update
21+
void Start()
22+
{
23+
// Project-Wide Actions
24+
move = InputSystem.actions.FindAction("Player/Move");
25+
look = InputSystem.actions.FindAction("Player/Look");
26+
attack = InputSystem.actions.FindAction("Player/Attack");
27+
jump = InputSystem.actions.FindAction("Player/Jump");
28+
interact = InputSystem.actions.FindAction("Player/Interact");
29+
next = InputSystem.actions.FindAction("Player/Next");
30+
previous = InputSystem.actions.FindAction("Player/Previous");
31+
sprint = InputSystem.actions.FindAction("Player/Sprint");
32+
crouch = InputSystem.actions.FindAction("Player/Crouch");
33+
}
34+
35+
// Update is called once per frame
36+
void Update()
37+
{
38+
if (attack.WasPressedThisFrame())
39+
{
40+
cube.GetComponent<Renderer>().material.color = Color.red;
41+
}
42+
else if (attack.WasReleasedThisFrame())
43+
{
44+
cube.GetComponent<Renderer>().material.color = Color.green;
45+
}
46+
47+
var moveVal = move.ReadValue<Vector2>();
48+
if (moveVal.x < 0.0f)
49+
{
50+
cube.transform.Translate(new Vector3(-10 * Time.deltaTime, 0, 0));
51+
}
52+
else if (moveVal.x > 0.0f)
53+
{
54+
cube.transform.Translate(new Vector3(10 * Time.deltaTime, 0, 0));
55+
}
56+
if (moveVal.y < 0.0f)
57+
{
58+
cube.transform.Translate(new Vector3(0, -10 * Time.deltaTime, 0));
59+
}
60+
else if (moveVal.y > 0.0f)
61+
{
62+
cube.transform.Translate(new Vector3(0, 10 * Time.deltaTime, 0));
63+
}
64+
}
65+
}
66+
#endif

Assets/Samples/ProjectWideActionsTest/ProjectWideActionsTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)