send object[] and recieve it

Hi, When i try to serialize a object[], i get the following error:

has no method "testSync" that takes 3 argument

how do i collect the object array as followed:
[RPC] 
	void testSync(object[] test) {
		
		Debug.Log(test.Length);
		
	}

is that possible?

Comments

  • Hmm. Good point.
    This is an ambivalence between the object[] used to call RPC and the object[] you want to get in the RPC. We don't handle RPC methods with object[] specifically, so this messes up currently.
    We will take a look.

    Meanwhile you could pass a object[] with your object[] in it.
  • I've taken a look but I'm not sure if we can fix this.

    The following code works, so we do support an object[] as long as extra paramters are passed as well.
    object[] myOBjs = new object[2];
                myOBjs[0] = 1;
                myOBjs[1] = 2;
                photonView.RPC("DoT", PhotonNetwork.player, myOBjs, true);
    

    However, passing ONLY a object[] will not work correctly because we have no way to detect whether the passed params were inididual params or 1 object[]. A solution is to wrap your object[] into another object[] when sending.http://stackoverflow.com/questions/36350/how-to-pass-a-single-object-to-a-params-object

    if (GUILayout.Button("RPC"))
            {
                object[] myOBjs = new object[2];
                myOBjs[0] = 1;
                myOBjs[1] = 2;
    
                photonView.RPC("DoT", PhotonNetwork.player, (object) myOBjs );
            }
    
     void DoT(object[] bla)
        {
            Debug.Log("GOT RPC " + bla.Length + " 0=" + bla[0]);
        }
    

    So, it needs just 1 extra cast from your side, when sending code only.
Sign In or Register to comment.