OnEnable not working.

Hello all.

I’m having some problems with a script. In the beginning I use OnEnable to set some value and instances whenever the object is enabled.

    void OnEnable()
    {
        instance = this;
        value1 = intance.iValue1;
        Debug.log("Instance set to this object.");
    }

This has been working just fine until today. I booted up Unity and I stopped getting OnEnable calls in all of my scripts. I don’t know if I messed with some setting, but I rely on OnEnable for a lot of scripts and I can’t change them to Awake (which is working) because of the nature of my game. I’d also like to note that OnDisable is working fine on any object/script. Anyone had this problem and know how to fix it? Thanks.

Edit: Restarted Unity, and now OnEnable works for all scripts except the one originally that was having the problem. :confused:

Check if your script disabled via UI or code

You’re replying to a post from over 5 years ago. Please check the dates of posts so you don’t end up necroing a thread again.

Thanks.