Exception: cannot serialize(): PlacementPlane

Hey Photon Community,

Ich habe zur zeit gerade ein Problem das der Status ob sie belegt ist oder nicht, meiner PlacementPlanes nicht über RPC schicken kann ... Er sagt sobald ich ein Turm platziere sagt er mir das er die Klasse vom PlacementPlane nicht Serialisieren kann. ich habe es System.Serializable gemacht. Kann es sein das sie beim Laden der Scene schon in der Scene liegen und nicht über Network Initialisiert wird ?

I have at the time a problem, the status of whether it is occupied or not, from my placement plan can not send via RPC ... He says as soon as I place a tower he tells me he can not serialize the class from the Placement Plane. I did it System.Serializable. Can it be that they are loading the scene already in the scene and is not Initializes over Network?

Sorry for the Bad english :D
Exception: cannot serialize(): PlacementPlane

ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)

ExitGames.Client.Photon.Protocol.SerializeObjectArray (System.IO.MemoryStream dout, System.Object[] objects, Boolean setType)

ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)

ExitGames.Client.Photon.Protocol.SerializeHashTable (System.IO.MemoryStream dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)

ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)

ExitGames.Client.Photon.Protocol.SerializeParameterTable (System.IO.MemoryStream memStream, System.Collections.Generic.Dictionary`2 parameters)

ExitGames.Client.Photon.Protocol.SerializeOperationRequest (System.IO.MemoryStream memStream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType)

ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opc, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt)

ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType)

ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted)

ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId, Boolean encrypt)

LoadbalancingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:496)

NetworkingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:925)

NetworkingPeer.RPC (.PhotonView view, System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2797)

PhotonNetwork.RPC (.PhotonView view, System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2409)

PhotonView.RPC (System.String methodName, PhotonTargets target, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:257)

Turret_MG_ORIGINAL.set_PlacePlane (.PlacementPlane value) (at Assets/EigeneAssests/Scritps/Turret_MG_ORIGINAL.cs:42)

Turret_Placement.Update () (at Assets/EigeneAssests/Scritps/Turret_Placement.cs:79)

Comments

  • You should register your class as custom type and specify serialize/deserialize methods to make PlacementPlane serializable by PUN:
    PhotonPeer.RegisterType(typeof(PlacementPlane), (byte)1, SerializePlacementPlane, DeserializePlacementPlane);
    
    2nd parameter is unique byte for your class. Make it different for different classes and try avoid conflicts with predefined classes which lay in letters range: 'A'-'Z' and 'a'-'z'. PhotonPeer.RegisterType returns false if you try to register with already taken byte.
  • To send the bool "occupied", you can put a PhotonView on the plane and use an RPC with a bool parameter.
    You don't HAVE to serialize the plane in this case, I'd say. It's much better not to use too many custom types.

    Read more on those here:
    http://doc.exitgames.com/en/realtime/cu ... -in-photon
  • WHat do you mean with PhotonView and RPC ?

    i have an PhotonView on the plane GameObject, and i have it in the c# script and i SEND bool
    public bool PlacePlane {
    		get{
    			return placePlane;
    		}
    		set{
    			if(PlayerPrefs.GetString("online").Equals("Online"))
    				view.RPC("SetPlacePlane",PhotonTargets.All,value);
    			else
    				placePlane = value;
    		}
    	}
    
            [RPC]
    	void SetPlacePlane(bool value){
    		placePlane = value;
    	}
    

    this is in the PlacementPlane Class
    i need to Send the Plane to the Turret so the plane nows he is full and if the turret get killed .. the turret says i am Dead and he set the plane to true

    I Fixed it, i dont always give the turret his Plane i search it with Raycast
    void OnDestroy(){
    		RaycastHit hit = new RaycastHit();
    		if (Physics.Raycast (transform.position, -transform.up,out hit,100,layerMask))
    			hit.collider.GetComponent<PlacementPlane>().PlacePlane = false;
    	}
    
  • > i dont always give the turret his Plane i search it with Raycast
    You should make the turret know it's plane and get rid of the raycast.