How to check if RPC function exists before calling RPC function
Options
Hi @Tobias
I want to check if RPC function exists before calling the function.
CHECK IF RPCCALL1 EXISTS
IF YES
ELSE SKIP
Thanks
I want to check if RPC function exists before calling the function.
CHECK IF RPCCALL1 EXISTS
IF YES
photonView.RPC("RPCCall1", PhotonTargets.MasterClient, PhotonNetwork.player);
ELSE SKIP
Thanks
0
Answers
-
Hi @JohnTube
I can't find any solution please help me
One client calls the RPC function and the target is MasterClient. The MasterClient only has a script contains the RPCCall1 function.
But the MasterClient exited so error happens.
Is there any solution to avoid this problem?0 -
Given that this post has existed for a month I'm afraid you may have already moved on, but allow me to lend advice anyway.sweetmei25 said:Hi @JohnTube
I can't find any solution please help me
One client calls the RPC function and the target is MasterClient. The MasterClient only has a script contains the RPCCall1 function.
But the MasterClient exited so error happens.
Is there any solution to avoid this problem?
Rather than checking whether an RPC exists or not, you might want to check if the script exists, so if the RPC exists on ScriptA.cs then do:ScriptA test = theObject.GetComponent<ScriptA>(); if(test != null) { // Do the RPC call then }
So basically, since you know Script A has the call, all you have to do is check that the object you're sending the RPC to has the script, and if it does then you know it also has the RPC.0 -
okay0
-
I already figured this problem out, but anyway thanks for your kind answer
Much appreciated! @kriller509 Thanks!0