neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.08k stars 892 forks source link

ObservableStateMachineTrigger issue when disabling animator or parent object #477

Open TheAtomAnt opened 3 years ago

TheAtomAnt commented 3 years ago

It seems that Unity will recreate the ObservableStateMachineTrigger instance when the animator or the object holding the animator (or any object up the hierarchy) is disabled and then reenabled. This causes any state subjects created to be recreated with the new instance of the ObservableStateMachineTrigger.

a debug.log statement in the ObservableStateMachineTrigger constructor will show it being created whenever an animator is enabled/disabled. I am worried that stuff isn't being cleaned up correctly when this happens too. Not sure how best to solve this...

allundo commented 1 year ago

It seems that all subscriptions of a ObservableStateMachineTrigger are disposed when applying SetActive(false) to the GameObject holding the Animator component...

allundo commented 1 year ago

It seems that all subscriptions of a ObservableStateMachineTrigger are disposed when applying SetActive(false) to the GameObject holding the Animator component...

Sorry...! I verified it with original StateMachineBehaviour component and the same problem happened. It's not a ObservableStateMachineTrigger issue.

cf. Unity Issue Tracker - [StateMachine] Reference to StateMachineBehaviour in script is lost after deactivating GameObject with AnimatorController