Cysharp/MessagePipe

[Bug] Message auto call 4 times when subscribe

hoanghai1308 opened this issue · 0 comments

I am using Zenject To use Messagepipe.
As the title suggests, the bug happened with my code structure below.

  • I have a state machine with 3 states:
  • LoadingState
  • GamePlayState
    +EndState
  • I have a Signal called RestartGameSignal already declared at SceneContext
  • I have A ClassA and on this call subscribe to RestartGameSignal at BindData() functions and unsubscribe At Dispose().

The flow:
When the game starts =>StateMachine transitions to LoadingState
+In LoadingState => Create ClassA via DiContainer of Zenject. with code

var instanceClassA=dicontainer.Instantiate();
instanceClassA.BindData().

After ClassA created and call BindData. I change the state to GamPlayState.
In the GamplayState I create an Update method from ITickable of zenject. When any Input from the keyboard is triggered, I fire RestartGameSignal => ClassA call Dispose() => transition to LoadingState

  • It bug appears. I found the issue here because of handlers.GetValues() has 4 elements of the array. Please fix it
image