Search Unity

Third Party PHOTON: RPC's thinking a string[] with only one string IS that string!

Discussion in 'Multiplayer' started by Peteroid69, Feb 20, 2022.

  1. Peteroid69

    Peteroid69

    Joined:
    Nov 11, 2018
    Posts:
    36
    if an RPC has as a string[] parameter (variable length array) and the string[] parameter used when calling it has exactly one element... then the RPC will NOT recognize it as a string array... and thinks it must use an NPC with a 'string' parameter in that place instead... (i.e... not a string array but just a single string)...
    .
    if the string[] parameter has 2 or more elements it recognizes the parameter just fine... only when it has exactly one element is this a problem... i have not yet tested the zero-element string array or null cases...
    .
    this is obviously a bug... i can't see how this could possibly be a working-as-intended feature... a bug which has not been fixed in many years...

    and yes... i know this belongs more in a PHOTON forum... and Unity is not the cause (i don't think)... but i feel mentioning this 'quirk' belongs here too... since it can be the source of a lot of heartache...
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    I think you need to work around this by explicitly passing an object[] to the parameters of the RPC method.
    Along these lines: new object[] { string[] yourStringArrayWithOneItem }.
    The quirk is (afaik) in our use of params object[] parameters as last parameter. It does not "get" your string[] is meant to be the first entry in the object[], instead of being the parameters array.