- Home /
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?
I keep testing more, and this time another input is doing it now. So I have basic controls 'a' = left, 'd' = right, ect, this time both 'a', and 'd' didn't work. The only thing I changed was applying changes to the prefab they were part of.
I also get a lot of warnings "The referenced script ($$anonymous$$) on this Behaviour is missing!" when I recompile.
Also just realized that the wronge IW's Update() isn't being called. $$anonymous$$aybe it would be better to update it through Update, and not OnValidate()?
Hey there,
so far recompilation during runtime has never worked for me. Perhaps depends on your setup. For me restarting is always the only option.
Yeah I have been trying to learn how to use it as it seems it would be insanely useful, but this is the main catch up I have faced so far. Unfortunately I can't find any resources about it.
Answer by Xavier78 · Mar 10, 2019 at 11:33 PM
Well hope this helps someone else that is in my position.
These IW I was passing to the manager get saved in an array.
Unity must make new copies of MonoBehaviors on recompile, so I was passing an old reference to the array.
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.
To fix this have a bool that calls something like _checkValues, and then pass the IW on update.
Your answer
![](https://koobas.hobune.stream/wayback/20220612193329im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Playmode script recompilation - static vars lost? 0 Answers
Resource compilation failed! Failed to recompile android resource files. 0 Answers
Serialize array of custom class in custom class 1 Answer
CommandInvokationFailure: Failed to re-package resources 0 Answers
Keep network socket open during play mode recompile 2 Answers