Hmm... if there's a split between how it works in-editor vs in-build, then it might have something to do with the Update()/OnValidate() cycle?
I tried running your code myself, and the strangest thing is, it works perfectly fine for me in-editor? What version of Unity are you using, and are you using the latest version of STM?