-1

I have two scripts. First script is named Launcher. It's derived from Photon.PunBehaviour and designed to work only with PUN methods. Also I have another script that is named LauncherUI and derived from MonoBehaviour.

Launcher has a reference of LauncherUI, so whenever something happens in the Launcher, it can change the UI by calling some of LauncherUI methods.

When a user joins to a room, public override void OnJoinedRoom() from the Launcher is called, but it also tries to call public void OnJoinedRoom(int[] playersID) from the LauncherUI, and this causes the next error

MissingMethodException: The best match for method OnJoinedRoom has some invalid parameter.

So why does the PUN call the two methods, even if one of them is in another class that isn't derived from Photon.PunBehaviour?

user2686299
  • 427
  • 8
  • 25

2 Answers2

0

It seems PUN uses Unity's SendMessage("MethodName") feature. It calls method with given name in each MonoBehaviour that is attached to a game object. In my case I have two scripts on the same game object that have two methods with the same name but with different parameters. So that's why that error happens.

user2686299
  • 427
  • 8
  • 25
0

PUN doesn't restrict callbacks to just Photon.PunBehaviour. It's optional to use and has some benefits but you can implement callbacks in any class (just as in Unity in general). You can set a type in PhotonNetwork.SendMonoMessageTargetType. This should restrict the callbacks to whatever you set.

Tobias
  • 164
  • 2