Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.8.0-pre.1] - 2023-08-14

### Added
- Initial version of Project Wide Actions for pre-release (`InputSystem.actions`). This feature is available only on Unity Editor versions 2022.3 and above and can be modified in the Project Settings.

### Fixed
- Fixed device selection menu not responding to mouse clicks when trying to add a device in a Control Scheme ([case ISXB-622](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-622)).
  • Loading branch information
Unity Technologies committed Aug 14, 2023
1 parent fc4c090 commit 62e2d39
Show file tree
Hide file tree
Showing 74 changed files with 2,277 additions and 146 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Due to package verification, the latest version below is the unpublished version and the date is meaningless.
however, it has to be formatted properly to pass verification tests.

## [1.8.0-pre.1] - 2023-08-14

### Added
- Initial version of Project Wide Actions for pre-release (`InputSystem.actions`). This feature is available only on Unity Editor versions 2022.3 and above and can be modified in the Project Settings.

### Fixed
- Fixed device selection menu not responding to mouse clicks when trying to add a device in a Control Scheme ([case ISXB-622](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-622)).

## [1.7.0] - 2023-08-14

### Added
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions Documentation~/PreReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Pre-Release Notes

## Overview

This pre-release contains updates to the Input System which simplifies and improves some of the main workflows compared with earlier versions of the Input System package.

Because this is a pre-release, the rest of the documentation included with this version of the package has not yet been updated to reflect these changes. The documentation on this page explains the improvements and differences between these new features, and the previous version of the input system package. The improvements are as follows:

**New project-wide actions**

The Input System now allows you to configure actions in the Project Settings window, in a new Input Actions Settings panel. The actions configured here apply project-wide. This means you no longer need to create an Actions asset and set up a reference to your asset to read input actions. Instead, you can configure your actions in the Project Settings window, and read them directly from your scripts. You can still use Action assets if you like, but for many typical scenarios, they are no longer necessary.

**New default actions**

The new project-wide actions come pre-loaded with some default action maps that contain actions suitable for many typical game scenarios, including basic player character controls, and typical UI interactions. In many cases these are enough to allow you to immediately start using input in your project with no configuration required. You are free to either add to, edit, or delete these default configurations to suit your needs.


**Note**: The new features in this pre-release are **only documented on this page**. When reading the rest of the documentation in this package, please remember that it *will not mention these features*. So, for example, when another page in the documentation discusses **action assets**, or creating a reference to your action asset, you can in many cases use project-wide actions instead, as described on this page.

## Project-wide actions and default actions

Project-wide actions are similar to the actions you would previously define in an actions asset, however instead of being an asset that you create in the Editor, they are stored as part of your project’s settings, and are configured in the Project Settings window.

Compared with the previous workflow of creating an Action asset, and setting up a reference to that asset to access in your code, project-wide actions reduce the number of steps to set up input in your project, and reduces complexity in your project.

![The Input Actions settings panel in the Project Settings window, showing the default player actions.](images/ProjectSettingsInputActions.png)<br/>
*The Input Actions settings panel in the Project Settings window, showing the default player actions.*

The project-wide actions feature has some default action maps set up, which you can add to, modify or delete. They are actions which are useful in typical games, such as moving a player character with WSAD keys or a Joypad stick, pressing a button to jump or interact, as well as common UI controls such as pointing, submitting, or canceling within a user interface.

**Note**: If you’d like to delete all the default actions so that you can start from an empty configuration, you don’t need to delete the actions individually. You can delete the default Action Maps, which deletes all the Actions contained in those maps in one go.

### Reading project-wide actions

You can access the project-wide actions in your script by using the [InputSystem.actions](../api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_actions) property. For example:

var myAction = InputSystem.actions.FindAction("Player/Jump");

The above line of code reads the "Jump" action, from the “Player” action map, which is one of the default actions that comes with the new project-wide actions feature.

Unlike Input Action assets, the project-wide actions are stored in your project’s Project Settings folder, so they do not appear in your Project window. The **InputSystem.actions** property is a built-in reference to that asset. This means you can use all the same techniques described throughout the rest of the documentation about [using action assets](Workflow-ActionsAsset.html), but instead of referencing an asset from your project, you can use the **InputSystem.actions property** in your scripts to reference the project-wide actions.

For example, here is the script from the [Action Assets workflow page](Workflow-ActionsAsset.html), adapted to use the project-wide actions, and the default actions in the "Player" action map.

```
using UnityEngine;
using UnityEngine.InputSystem;
public class ExampleScript : MonoBehaviour
{
// private field to store move action reference
private InputAction moveAction;
void Awake()
{
// find the "move" action, and keep the reference to it, for use in Update
moveAction = InputSystem.actions.FindAction("Player/move");
// for the "jump" action, we add a callback method for when it is performed
InputSystem.actions.FindAction("Player/jump").performed += OnJump;
}
void Update()
{
// our update loop polls the "move" action value each frame
Vector2 moveVector = moveAction.ReadValue<Vector2>();
}
private void OnJump(InputAction.CallbackContext context)
{
// this is the "jump" action callback method
Debug.Log("Jump!");
}
}
```

Things to note about the above example script, as compared to the script on the [Action Assets workflow page](Workflow-ActionsAsset.html):

* Because there is a built-in reference to the project-wide actions, you do not need a public field with an assigned asset to get a reference to the actions.

* This script does not enable or disable action maps. Project-wide action maps are enabled by default. This means unlike with Action assets, you do not need to enable individual action maps in your script before being able to use them. You may still want to disable or enable action maps if you want to make use of different types of input in different parts of your project.

### Limitations

Because this is a pre-release, the project-wide actions feature is not yet complete and has some limitations you should be aware of.

**The project-wide actions cannot be referenced in an ActionsAsset field in the inspector.**

You can't assign the project-wide input actions asset to UI fields where you would normally assign an input action asset. For example, if you are using the PlayerInput component, you can’t assign the project wide actions to its "Actions" field. This means if you want to use the PlayerInput component, you must create an Actions asset and set up your input configuration there instead of in the project-wide actions.

**Some features of the project-wide actions editor are different, or missing, compared with the Actions Editor window for actions assets.**

Although the UI to edit the project-wide actions in the Project Settings window is very similar to the Actions Editor for action assets, there are some differences and missing features. In particular, the new project-wide actions editor uses a newer UI system, and therefore there are some cosmetic differences such as different icons, and some workflow features are missing such as some of the keyboard shortcuts. You also cannot yet access the project-wide actions [through a C# wrapper](Workflow-ActionsAsset.html#referencing-the-actions-asset-through-a-c-wrapper).
1 change: 1 addition & 0 deletions Documentation~/TableOfContents.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* [Important Pre-Release Notes](PreReleaseNotes.md)
* [Introduction](index.md)
* [Installation](Installation.md)
* [Concepts](Concepts.md)
Expand Down
1 change: 1 addition & 0 deletions Documentation~/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "DefineConstants": "UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS" }
2 changes: 1 addition & 1 deletion InputSystem/Actions/Composites/Vector2Composite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public override void OnGUI()
target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var modeField = new EnumField("Mode", target.mode)
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Composites/Vector3Composite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public override void OnGUI()
target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var modeField = new EnumField("Mode", target.mode)
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/InputControlScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public InputControlScheme(string name, IEnumerable<DeviceRequirement> devices =
}
}

#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
internal InputControlScheme(SerializedProperty sp)
{
var requirements = new List<DeviceRequirement>();
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Interactions/HoldInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public override void OnGUI()
m_DurationSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback);
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Interactions/MultiTapInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public override void OnGUI()
m_PressPointSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var tapCountField = new IntegerField(m_TapCountLabel.text) { value = target.tapCount };
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Interactions/PressInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public override void OnGUI()
m_PressPointSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
root.Add(new HelpBox(s_HelpBoxText.text, HelpBoxMessageType.None));
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Interactions/SlowTapInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override void OnGUI()
m_PressPointSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
m_DurationSetting.OnDrawVisualElements(root, onChangedCallback);
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Actions/Interactions/TapInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public override void OnGUI()
m_PressPointSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
m_DurationSetting.OnDrawVisualElements(root, onChangedCallback);
Expand Down
4 changes: 2 additions & 2 deletions InputSystem/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static partial class InputSystem
// Keep this in sync with "Packages/com.unity.inputsystem/package.json".
// NOTE: Unfortunately, System.Version doesn't use semantic versioning so we can't include
// "-preview" suffixes here.
internal const string kAssemblyVersion = "1.7.0";
internal const string kDocUrl = "https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7";
internal const string kAssemblyVersion = "1.8.0";
internal const string kDocUrl = "https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8";
}
}
2 changes: 1 addition & 1 deletion InputSystem/Controls/Processors/AxisDeadzoneProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public override void OnGUI()
m_MaxSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
m_MinSetting.OnDrawVisualElements(root, onChangedCallback);
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Controls/Processors/StickDeadzoneProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override void OnGUI()
m_MaxSetting.OnGUI();
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
m_MinSetting.OnDrawVisualElements(root, onChangedCallback);
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Devices/Precompiled/FastKeyboard.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator
// version 1.7.0
// version 1.8.0
// from "Keyboard" layout
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Devices/Precompiled/FastMouse.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator
// version 1.7.0
// version 1.8.0
// from "Mouse" layout
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Devices/Precompiled/FastTouchscreen.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator
// version 1.7.0
// version 1.8.0
// from "Touchscreen" layout
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
5 changes: 2 additions & 3 deletions InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ internal class InputActionEditorWindow : EditorWindow, IDisposable
[OnOpenAsset]
public static bool OnOpenAsset(int instanceId, int line)
{
#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
if (InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseUIToolkitEditor))
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseUIToolkitEditorForAllAssets))
return false;
#endif

var path = AssetDatabase.GetAssetPath(instanceId);
if (!path.EndsWith(k_FileExtension, StringComparison.InvariantCultureIgnoreCase))
return false;
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Editor/AssetEditor/ParameterListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void Clear()
m_ParameterEditor = null;
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public void OnDrawVisualElements(VisualElement root)
{
if (m_ParameterEditor != null)
Expand Down
17 changes: 14 additions & 3 deletions InputSystem/Editor/InputParameterEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class InputParameterEditor
/// </summary>
public abstract void OnGUI();

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
/// <summary>
/// Add visual elements for this parameter editor to a root VisualElement.
/// </summary>
Expand Down Expand Up @@ -182,6 +182,17 @@ internal override void SetTarget(object target)
OnEnable();
}

#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
/// <summary>
/// Default stub implementation of <see cref="InputParameterEditor.OnDrawVisualElements"/>.
/// Should be overridden to create the desired UI.
/// </summary>
public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
}

#endif

/// <summary>
/// Helper for parameters that have defaults (usually from <see cref="InputSettings"/>).
/// </summary>
Expand Down Expand Up @@ -212,7 +223,7 @@ public void Initialize(string label, string tooltip, string defaultName, Func<fl
$"Uses \"{defaultName}\" set in project-wide input settings.");
}

#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
public void OnDrawVisualElements(VisualElement root, Action onChangedCallback)
{
var value = m_GetValue();
Expand Down Expand Up @@ -373,7 +384,7 @@ public void OnGUI()
private FloatField m_FloatField;
private Button m_OpenInputSettingsButton;
private Toggle m_DefaultToggle;
#if UNITY_INPUT_SYSTEM_UI_TK_ASSET_EDITOR
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
private HelpBox m_HelpBox;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ internal class AdvancedDropdownGUI
{
private static class Styles
{
#if UNITY_2023_2_OR_NEWER || UNITY_2021_3_28 || UNITY_2022_3_1
public static readonly GUIStyle toolbarSearchField = "ToolbarSearchTextField";
#else
public static readonly GUIStyle toolbarSearchField = "ToolbarSeachTextField";
#endif
public static readonly GUIStyle toolbarSearchField = EditorStyles.toolbarSearchField;
public static readonly GUIStyle itemStyle = new GUIStyle("PR Label")
.WithAlignment(TextAnchor.MiddleLeft)
.WithPadding(new RectOffset())
Expand Down
8 changes: 8 additions & 0 deletions InputSystem/Editor/ProjectWideActions.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 62e2d39

Please sign in to comment.