None existent object instance getting updated on recompile while playing.

I have an Input wrapper(IW) management system. Each time the editor recompiles during run time I have to resend these IW to the manager(which I do on OnValidate). When this happens somehow a none existent reference of an IW gets updated, but not the actualy one, which has a keycode of ‘A’. This wrong IW has the input keycode ‘Q’, and when I debug the game object it is attached to it doesn’t reference one that is in the scene, but it is named what it should be. At one point I did have ‘Q’ set as the keycode, but I changed it. What is happening here, and how do I make sure this doesn’t happen again?

Well hope this helps someone else that is in my position.

  1. These IW I was passing to the manager get saved in an array.
  2. Unity must make new copies of MonoBehaviors on recompile, so I was
    passing an old reference to the
  3. There is no easy way to tell if the object is old, you can look at
    its values, and also it’s Update
    won’t be call.
  4. To fix this have a bool that calls something like _checkValues,
    and then pass the IW on update.