Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ however, it has to be formatted properly to pass verification tests.
- Project-wide input actions template extension changed from .inputactions to .json. This avoids showing template actions in the action's selector UI that are not intended to be used.
- Re-enabled some UI tests that were disabled on iOS.
- Reorganized package Project Settings so that "Input System Package" setting node contains "Input Actions" and "Settings" becomes a child node when Project-wide Actions are available. For Unity versions where Project-wide Actions are not available, the settings structure remains unchanged.
- Make Project-wide Actions the default actions for Player Input.

### Added
- Support for [Game rotation vector](https://developer.android.com/reference/android/hardware/Sensor#TYPE_GAME_ROTATION_VECTOR) sensor on Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using UnityEngine.InputSystem.Users;
using UnityEngine.InputSystem.Utilities;

#if UNITY_EDITOR
using UnityEngine.InputSystem.Editor;
#endif

#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
using UnityEngine.InputSystem.UI;
#endif
Expand Down Expand Up @@ -1607,6 +1611,15 @@ private void AssignPlayerIndex()
}
}

#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
void Reset()
{
// Set default actions to project wide actions.
m_Actions = ProjectWideActionsAsset.GetOrCreate();
}

#endif

private void OnEnable()
{
m_Enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void OnInspectorGUI()
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_ActionsProperty);
var actionsWereChanged = false;
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized)
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || CheckIfActionAssetChanged())
{
OnActionAssetChange();
actionsWereChanged = true;
Expand Down Expand Up @@ -230,6 +230,22 @@ public override void OnInspectorGUI()
DoDebugUI();
}

// This checks changes that are not captured by BeginChangeCheck/EndChangeCheck.
// One such case is when the user triggers a "Reset" on the component.
bool CheckIfActionAssetChanged()
{
if (m_ActionsProperty.objectReferenceValue != null)
{
var assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
bool result = assetInstanceID != m_ActionAssetInstanceID;
m_ActionAssetInstanceID = (int)assetInstanceID;
return result;
}

m_ActionAssetInstanceID = -1;
return false;
}

private void DoHelpCreateAssetUI()
{
if (m_ActionsProperty.objectReferenceValue != null)
Expand Down Expand Up @@ -566,6 +582,7 @@ void AddEntry(InputAction action, PlayerInput.ActionEvent actionEvent)

[NonSerialized] private bool m_NotificationBehaviorInitialized;
[NonSerialized] private bool m_ActionAssetInitialized;
[NonSerialized] private int m_ActionAssetInstanceID;
}
}
#endif // UNITY_EDITOR