unity3d – Photon Exception: Write failed. Custom type not found: UnityEngine.GameObject

Hey Guys I have some problem about Photon. Here is The code;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class FinishManager : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Legs"))
        {
            collision.gameObject.GetComponent<PhotonView>().RPC("Win", RpcTarget.All, collision.gameObject); /*Here is the error line*/
        }
    }


    [PunRPC]
    public void Win(GameObject player)
    {
        PhotonNetwork.Destroy(player);
    }

}

The problem is this:

Exception: Write failed. Custom type not found: UnityEngine.GameObject ExitGames.Client.Photon.Protocol18.WriteCustomType (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at D:/Dev/Work/photon-dotnet- sdk/PhotonDotNet/Protocol18Write.cs:732) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, ExitGames.Client.Photon.Protocol18+GpType gpType, writeType) System. (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:96) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:26) ExitGames.Client.Photon.Protocol18.WriteObjectArray (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.IList array , System.Boolean writeType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:639) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Cl ient.Photon.StreamBuffer stream, System.Object value, ExitGames.Client.Photon.Protocol18+GpType gpType, System.Boolean writeType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:156) ) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs) :26) ExitGames.Client.Photon.Protocol18.WriteHashtable (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write) .cs:431) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, ExitGames.Client.Photon.Protocol18+GpType gpType, System.Boolean writeType) (at D:/ Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:129) ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean wri teType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:26) ExitGames.Client.Photon.Protocol18.WriteParameterTable (ExitGames.Client.Photon.StreamBuffer stream, ExitGamnes.Client. ParameterDictionary parameters) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:238) ExitGames.Client.Photon.Protocol18.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, operationCodeB. ExitGames.Client.Photon.ParameterDictionary parameters, System.Boolean setType) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/Protocol18Write.cs:273) ExitGames.Client.Photon.PeerBase.SerializeOperationSteyMesteys opCode, ExitGames.Client.Photon.ParameterDictionary parameters, ExitGames.Client.Photon.EgMessageType messageType, System.Boolean encrypt) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:683). Client.Photon.PhotonPeer.SendOperation (System.Byte operationCode, ExitGames.Client.Photon.ParameterDictionary operationPa rameters, ExitGames.Client.Photon.SendOptions sendOptions) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1863) Photon.Realtime.LoadBalancingPeer.OpRaiseEvent (System.Byte.ObjectCode, System) customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/Photon/PhotonRealtime/Code/LoadbalancingPeer.cs:965) customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2176) Photon.Pun.PhotonNetwork.RaiseObjectEventCo.internal,Sytem.Syte eventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2351) Photon.Pun.PhotonNetwork.RPC (Photon.Pun.Syn.PhotonView) tem.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1263) Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2940) Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Pun.RpcTarget target, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:604) FinishManager.OnCollisionEnter2D (UnityEngine.Collision2D collision) (at Assets/FinishManager.cs:13)

Leave a Comment