@@ -300,8 +300,8 @@ private void BuildDestinationToTransitionInfoTable()
300300 }
301301
302302 /// <summary>
303- /// Gets the transition info for a destination state, preferring the entry that starts from the originating state
304- /// since several states can transition into the same destination.
303+ /// Gets the transition info for a destination state, matched by originating state since several states can
304+ /// transition into the same destination. Transitions not in the table, such as non-trigger ones, return false .
305305 /// </summary>
306306 internal bool TryGetTransitionInfo ( int layer , int destinationState , int originatingState , out TransitionStateInfo transitionInfo )
307307 {
@@ -311,16 +311,15 @@ internal bool TryGetTransitionInfo(int layer, int destinationState, int originat
311311 return false ;
312312 }
313313
314- transitionInfo = transitions [ 0 ] ;
315314 foreach ( var entry in transitions )
316315 {
317316 if ( entry . OriginatingState == originatingState )
318317 {
319318 transitionInfo = entry ;
320- break ;
319+ return true ;
321320 }
322321 }
323- return true ;
322+ return false ;
324323 }
325324
326325 [ Serializable ]
@@ -493,7 +492,11 @@ private void ParseStateMachineStates(int layerIndex, ref AnimatorController anim
493492 foreach ( var childStateMachine in stateMachine . stateMachines )
494493 {
495494 var nestedStateMachine = childStateMachine . stateMachine ;
496- ParseStateMachineStates ( layerIndex , ref animatorController , ref nestedStateMachine , childStateMachineParents ) ;
495+ // A missing sub-state machine asset reference leaves this null
496+ if ( nestedStateMachine != null )
497+ {
498+ ParseStateMachineStates ( layerIndex , ref animatorController , ref nestedStateMachine , childStateMachineParents ) ;
499+ }
497500 }
498501 }
499502
@@ -1104,14 +1107,11 @@ private void WriteSynchronizationData<T>(ref BufferSerializer<T> serializer) whe
11041107 stateHash = nextState . fullPathHash ;
11051108
11061109 // Check if this transition can be synchronized using cross-fading
1107- if ( m_DestinationStateToTransitionInfo . ContainsKey ( layer ) )
1110+ if ( TryGetTransitionInfo ( layer , nextState . shortNameHash , synchronizationStateInfo . shortNameHash , out var transitionInfo ) )
11081111 {
1109- if ( TryGetTransitionInfo ( layer , nextState . shortNameHash , synchronizationStateInfo . shortNameHash , out var transitionInfo ) )
1110- {
1111- stateHash = transitionInfo . OriginatingState ;
1112- // Set the destination state to cross-fade to from the originating state
1113- animationState . DestinationStateHash = transitionInfo . DestinationState ;
1114- }
1112+ stateHash = transitionInfo . OriginatingState ;
1113+ // Set the destination state to cross-fade to from the originating state
1114+ animationState . DestinationStateHash = transitionInfo . DestinationState ;
11151115 }
11161116 }
11171117
0 commit comments