OnEnable() hinders to call OnJoinedRoom()

Options
Hello everyone,
I have a problem with the OnEnable() method. Since I use MonoBehaviourPunCallbacks, the PUN OnEnable() is being called. And I need to call OnEnable() but if I call that instead of Start(), the OnJoinedRoom() method from PUN isn't called anymore. But it works perfectly with Start(). And the code inside shouldn't actually affect this.
I also get a "warning" (the OnEnable() is underlined with green) that my OnEnable() method "hides" the MonoBehaviourPunCallbacks.OnEnable() member. And it suggests me to use this method with public override. But this doesn't work at all. I tried every combination (public, override, virtual, protected, private) but no one works. I also tried MonoBehaviourPunCallbacks.OnEnable() but it doesn't let me do that.

I would be very happy if someone could help me.

Thank you already in advance

Comments

  • S_Oliver
    S_Oliver ✭✭✭
    Options
    Thats basic inheritance.If you dont know about this stuff you better watch some tutorials.
    MonoBehaviourPunCallbacks uses OnEnable to register all the Callbacks you want to use.
    If you override OnEnable the callbacks are not registered, you have to call base.OnEnable(); in OnEnable.
    So your code should look like this
    	public override void OnEnable()
    	{
    		base.OnEnable();
    		//your stuff here
    	}