PlayerInput - SendMessages not working after changing the scene

I instantiated two prefabs with PlayerInput attached using a PlayerInputManager. In the first scene the PlayerInput-Scripts worked fine with my own scripts (lets call them scripts a). The Behavior of PlayerInput is set to SendMessages. The Gameobject with the PlayerInputManager and both PlayerInput-Prefabs are set to DontDestroyOnLoad. When Scene 2 begins i replaced scripts a with scripts b wich also should receive the SendMessages by PlayerInput, but they dont. I also tried it without replacing but it doesnt work with script a too. Does someone know the reason why?

May be some problems if you don’t let the garbage collector destroy old objects and then using smth like “Find object of type” or any other Find functions which can return you reference to old object from memory instead of new one.

  • I’ve suffered this behaviuor when made static C# events and didn’t unsubscribe from them or set the reference to MonoBehaviour or Component or GameObject to static field and not set it to null when scene reloads. Since these times I almost never use static refs to objects.

  • Also if you not cleaning up references from your manager to objects which should be destroyed it can behave like that because you don’t let GC collect these objects and they’re still in memory.