Not receiving Callbacks on Scriptable Object

Options
XADev
XADev

Hello

I have a scriptable object that implements IConnectionCallbacks.

When I connect to the server, I do not receive OnConnectedToMaster (i.e. the debug.log inside it does not show in the console).

When I add a MonoBehaviourPunCallbacks, I can receive the callback through it (but not through the ScriptableObject).

I tried registering using OnEnable, but still did not work:

LoadBalancingClient lb;

private void OnEnable()

       {

         if (lb == null)

            lb = new LoadBalancingClient();

         lb.AddCallbackTarget(this);

      }

      private void OnDisabled()

      {

         lb.RemoveCallbackTarget(this);

      }

And tried:

private void OnEnable()

       {

         Debug.Log("Enable");

         PhotonNetwork.AddCallbackTarget(this);

       }

       private void OnDisable()

       {

         Debug.Log("Disable");

         PhotonNetwork.RemoveCallbackTarget(this);

      }

Thank you!

Answers

  • XADev
    Options

    As far as I understand, the docs said OnEnable and OnDisable should work, but they didn't.

    To solve it, I had to make an explicit function and use it to call the AddCallbackTarget();