Write Error When Using photonView.RPC
Options
I'm new to photon and am clearly missing a core concept with RPC's as I am currently getting an error I don't understand. I am trying to create a simple ready up system within a room before launching the first level using Unity's Toggle UI and passing a boolean value. I am just trying to ensure the host and client can see the UI changes first off.
Here is the code triggered by the toggle which sends an RPC
When I join the room as the client I get this error "Exception: Write failed. Custom type not found: UnityEngine.UI.Toggle". If need be I will post the rest of the error log, however, I imagine someone will be able to recognize what I am doing wrong without flooding this post lol.
I don't what is happening when the client recieves the RPC and why the error is occuring. I've tried reading the API but in my mind this should work. Thanks in advanced!
Here is the code triggered by the toggle which sends an RPC
public void ChangeReadyStatus(bool status) { Toggle targetToggle; Text targetText; RpcTarget rpcTarget; if(PhotonNetwork.IsMasterClient && PhotonNetwork.CurrentRoom.PlayerCount > 1) { targetToggle = LaunchManager.instance.roomMenu.player1Toggle; targetText = LaunchManager.instance.roomMenu.player1ToggleText; rpcTarget = RpcTarget.Others; } else { targetToggle = LaunchManager.instance.roomMenu.player2Toggle; targetText = LaunchManager.instance.roomMenu.player2ToggleText; rpcTarget = RpcTarget.MasterClient; } if (status == true) targetText.color = Color.green; else targetText.color = Color.red; photonView.RPC("RPC_ChangeReadyStatus", rpcTarget, targetToggle, targetText, status); } #region Pun RPC's [PunRPC] public void RPC_ChangeReadyStatus(Toggle targetToggle, Text targetText, bool status) { if (status == true) { targetToggle.isOn = true; targetText.color = Color.green; } else { targetToggle.isOn = false; targetText.color = Color.red; } } #endregion
When I join the room as the client I get this error "Exception: Write failed. Custom type not found: UnityEngine.UI.Toggle". If need be I will post the rest of the error log, however, I imagine someone will be able to recognize what I am doing wrong without flooding this post lol.
I don't what is happening when the client recieves the RPC and why the error is occuring. I've tried reading the API but in my mind this should work. Thanks in advanced!
0
Comments
-
You can't send a component with a rpc.
Check out this https://doc.photonengine.com/en-us/pun/v2/gameplay/rpcsandraiseevent1 -
Okay so I missed a core concept then! Changed the RPC to only send the bool and can now adjust the UI appropriately. Thanks!1