2

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!

derHugo
  • 83,094
  • 9
  • 75
  • 115
Vallout
  • 41
  • 6
  • 1
    is it possible that the build on the HoloLens is not up-to-date => the RPCs are all stored on built-time with a certain index ... when you call that method it instead only sends the according index over the network and then on receiver side tries to find the method for that index again ... => if these indices / registered RPC methods do not match across all instances/builds in your network then this would lead to your error / unexpected behavior. In particular this might happen if you have any RPCs under platform dependent compilation or simply different versions of your app – derHugo Oct 21 '21 at 08:41
  • This sounds reasonable. Still, the PUN versions are definitely equal. I ran these tests in the editor. There exist no other RPCs in this test-case. Is there some way to do a "clean" or something in unity? – Vallout Oct 21 '21 at 08:53

1 Answers1

2

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.

Vallout
  • 41
  • 6
  • Always very happy if people find the solution on their own after only needing a little hint in the right direction ^_^ – derHugo Oct 21 '21 at 09:23