Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OnDisable is Calling After OnDestroy

Discussion in 'Scripting' started by lavz24, Sep 17, 2014.

  1. lavz24

    lavz24

    Joined:
    Mar 14, 2013
    Posts:
    45
    Hi,

    I have a problem, in the Unity Documentation it said: OnDisable is call before OnDestroy.

    Well, I have two script A and B (Singleton).

    A call OnDisable and OnDestroy after B OnDisable and OnDestroy. this brings me many problems because A is subscribe delegate method to B and unsubscribe the method in OnDisable, but if onDestroy of B is calling first when is call A OnDisable B is null.

    Any help ??

    Thanks
     
  2. Fraconte

    Fraconte

    Joined:
    Dec 6, 2013
    Posts:
    327
    Make the delegate/event static.
     
    Infenix and lavz24 like this.
  3. lavz24

    lavz24

    Joined:
    Mar 14, 2013
    Posts:
    45
    Thanks