Skip to content

Commit 007412e

Browse files
committed
Corrected and updated inline doc for InputActionReference invalidation
1 parent 22be817 commit 007412e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionReference.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ public InputAction action
5252
{
5353
get
5454
{
55-
// Note that we check m_Action since it would be null if we haven't yet resolved the action.
56-
// We also need to check that m_Action.actionMap isn't null since it would be null if the
57-
// action was deleted. Additionally we need to check m_Asset since it could also have been deleted.
58-
if (m_Action != null && m_Action.actionMap != null && m_Asset)
55+
// Note that we need to check multiple things here that could invalidate the validity of the reference:
56+
// 1) m_Action != null, this indicates if we have a resolved cached reference.
57+
// 2) m_Action.actionMap != null, this would fail if the action has been removed from an action map
58+
// and converted into a "singleton action". This would render the reference invalid since the action
59+
// is no longer indirectly bound to m_Asset.
60+
// 3) m_Action.actionMap.asset == m_Asset, needs to be checked to make sure that its action map
61+
// have not been moved to another asset which would invalidate the reference since reference is
62+
// defined by action GUID and asset reference.
63+
// 4) m_Asset, a Unity object life-time check that would fail if the asset has been deleted.
64+
if (m_Action != null && m_Action.actionMap != null && m_Action.actionMap.asset == m_Asset && m_Asset)
5965
return m_Action;
6066

6167
// Attempt to resolve action based on asset and GUID.

0 commit comments

Comments
 (0)