Skip to content

Commit 0c988bb

Browse files
CHANGE: Update from InstanceID to EntityId in PlayerInputEditor.cs (#2325)
1 parent a83a39f commit 0c988bb

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

Assets/Editor/DumpInputActionReferences.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ private static void DumpReferences(StringBuilder sb, string prefix, InputActionR
1919
private static void DumpReferences()
2020
{
2121
var sb = new StringBuilder();
22+
#pragma warning disable CS0618 // Type or member is obsolete
2223
DumpReferences(sb, "Loaded objects", Object.FindObjectsByType<InputActionReference>(
2324
FindObjectsInactive.Include, FindObjectsSortMode.InstanceID));
25+
#pragma warning restore CS0618 // Type or member is obsolete
2426
DumpReferences(sb, "All objects:", Resources.FindObjectsOfTypeAll<InputActionReference>());
2527
Debug.Log(sb.ToString());
2628
}

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ however, it has to be formatted properly to pass verification tests.
1111
## [Unreleased] - yyyy-mm-dd
1212

1313
### Changed
14-
- Consecutive wildcard characters ('*') used in input control-paths are now collapsed into a single wildcard when multiple consecutive wildcard characters are present.
1514

16-
### Added
15+
- Updated `m_ActionAssetInstanceID` in PlayerInputEditor.cs to use `EntityId` instead of `InstanceID`.
16+
- Consecutive wildcard characters ('*') used in input control-paths are now collapsed into a single wildcard when multiple consecutive wildcard characters are present.
1717

1818
### Fixed
1919

20+
### Added
2021

2122
## [1.18.0] - 2026-01-14
2223

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ public override void OnInspectorGUI()
9797

9898
var assetChanged = CheckIfActionAssetChanged();
9999
// initialize the editor component if the asset has changed or if it has not been initialized yet
100+
#if UNITY_6000_4_OR_NEWER
101+
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetEntityId == EntityId.None)
102+
#else
100103
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetInstanceID == 0)
104+
#endif
101105
{
102106
InitializeEditorComponent(assetChanged);
103107
actionsWereChanged = true;
@@ -276,26 +280,22 @@ public override void OnInspectorGUI()
276280
// One such case is when the user triggers a "Reset" on the component.
277281
bool CheckIfActionAssetChanged()
278282
{
279-
if (m_ActionsProperty.objectReferenceValue != null)
280-
{
281-
// 6.4 deprecates instance id in favour of entity ids (a class)
282-
// Fortunately, there is an implicit cast from entity id to an integer so we can have minimum footprint for now.
283-
int assetInstanceID;
284-
285-
#if UNITY_6000_4_OR_NEWER
286-
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetEntityId();
287-
#else
288-
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
289-
#endif
290-
291-
// if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
292-
bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
293-
m_ActionAssetInstanceID = (int)assetInstanceID;
294-
return result;
295-
}
296-
297-
m_ActionAssetInstanceID = -1;
298-
return false;
283+
var obj = m_ActionsProperty.objectReferenceValue;
284+
if (obj == null)
285+
return false;
286+
287+
#if UNITY_6000_4_OR_NEWER
288+
EntityId assetEntityId = obj.GetEntityId();
289+
bool result = assetEntityId != m_ActionAssetEntityId && m_ActionAssetEntityId != EntityId.None;
290+
m_ActionAssetEntityId = assetEntityId;
291+
return result;
292+
#else
293+
int assetInstanceID = obj.GetInstanceID();
294+
// if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
295+
bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
296+
m_ActionAssetInstanceID = (int)assetInstanceID;
297+
return result;
298+
#endif
299299
}
300300

301301
private void DoHelpCreateAssetUI()
@@ -656,7 +656,11 @@ void AddEntry(InputAction action, PlayerInput.ActionEvent actionEvent)
656656

657657
[NonSerialized] private bool m_NotificationBehaviorInitialized;
658658
[NonSerialized] private bool m_ActionAssetInitialized;
659+
#if UNITY_6000_4_OR_NEWER
660+
[NonSerialized] private EntityId m_ActionAssetEntityId;
661+
#else
659662
[NonSerialized] private int m_ActionAssetInstanceID;
663+
#endif
660664
}
661665
}
662666
#endif // UNITY_EDITOR

0 commit comments

Comments
 (0)