Search code examples
c#unity-game-enginephoton

Error: "RPC method not found" on method that was never called


I have a really strange problem. Currently I am working on a little cross platform "game", where one user wears a Hololens and another user sits at the PC. The Hololens user solves a puzzle while the PC user helps the Hololens user by giving hints by e.g. highlighting elements.

In the application I have a parent Element ("Puzzle") and its children ("Part-X"). Every part ("Part-X") has a Property Manager Script:

public class PropertyManager : MonoBehaviour
{
    private Renderer rend;
    public int identifier;
    private Color initColor;

    void Start()
    {
        rend = GetComponent<Renderer>();
        initColor = rend.material.color;
    }


    public void Highlight()
    {
        rend.material.color = Color.red;
    }

    public void Unhighlight()
    {
        rend.material.color = initColor;
    }

    [PunRPC]
    public void activeElemHandling(int viewId)
    {
        transform.parent.GetComponent<ComponentHandler>().handleActiveElement(viewId);
    }
}

The parent has a script with the function "handleActiveElement":

public void handleActiveElement(int newActiveId)
{
    foreach (Transform child in transform)
    {
        # set highlight color for new active element and unhighlight all other elements
        if (child.GetComponent<PhotonView>().ViewID == newActiveId)
        {

            child.GetComponent<PropertyManager>().Highlight();
        }
        else
        {
            child.GetComponent<PropertyManager>().Unhighlight();
        }
    }
}

Now I fire the RPC from the PC user this way:

void OnMouseDown()
{
    int viewId = photonView.ViewID;
    PropertyManager manager = GetComponent<PropertyManager>();
    string functionName = nameof(manager.activeElemHandling);
    photonView.RPC(functionName, RpcTarget.All, viewId); # It works the same by providing the plain string 'activeElemHandling'

While the result works for the application on the side of the PC-Application, it does not work on the side of the Hololens Application. Here I get a really strange error:

RPC method 'setChildren(Int32)' not found on object with PhotonView XXXX

I never called a RPC method 'setChildren' and I also don't want to call it. I have looked into this for several hours now and I don't find a solution. If someone has an idea how to solve it, I highly appreciate that. Thanks!


Solution

  • Ok, I solved the issue after the impulse of derHugo. Thank you very much!

    I needed to reset the RPCs on both sides. This is possible by locating the PhotonServerSettings.asset-File and opening the segment "RPCs", where the RPCs can be reset by clicking on "Clear RPCs". And it's working.