Has the way of sending array of types changed?

Hi,

I've upgraded my unity and photon to latest versions and now it seems that the array of int[] that I was sending thru stream is not working anymore... has the way of sending and receiving arrays changed?

Example:
   void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
                //We own this player: send the others our data
                stream.SendNext((int[])characterEnums.states);
                stream.SendNext(transform.position);
                stream.SendNext(transform.rotation);
                stream.SendNext(weaponState.aimTarget.position);
                stream.SendNext((Vector3)controllerScript.directionVector);
        }
        else
        {
            	//Network player, receive data
			
                characterEnums.states = (int[])stream.ReceiveNext();
                correctPlayerPos = (Vector3)stream.ReceiveNext();
                correctPlayerRot = (Quaternion)stream.ReceiveNext();
                correctAimTarget = (Vector3)stream.ReceiveNext();
                controllerScript.directionVector = (Vector3)stream.ReceiveNext();
	}
		

    }



Thanks!

Comments

  • No, that should not be changed at all.
    PUN 1.16 and Photon 3 final?
    Do you get a error message on either client or server?
  • PUN 1.16.2 (from asset store) and Photon Cloud. No errors at all. It simply stopped working.
  • I am using the cloud and int[] regularly. So that really shouldn't be an issue.

    What about:
    stream.SendNext((int[])characterEnums.states);

    characterEnums? That sounds like an enum. Is states really a int[] in that case?
    Can you post the definition of that?
  • Yes, it sounds a little confusing indeed. I should have named the class as CharacterStates. But this is the class definition:
    using UnityEngine;
    using System;
    using System.Collections;
    using System.IO;
    using System.Text;
    
    public enum CharacterStateCustom
    {
        Idle = 0,
        Walking = 1,
        Trotting = 2,
        Running = 3,
        Jumping = 4,
    	Attacking = 5,
    	PointingGun = 6,
    	Firing = 7,
    	HolstingGun = 8,
    	Dead = 9,
    	Burning = 10
    
    }
    
    public class CharacterEnums : MonoBehaviour
    {
    
    	public CharacterStateCustom state;
    	int _statesArrayInt = 0;
    	public string MyName = "DefaultName";
    	public int[] states = new int[4];
    	public float myFloat;
    	
    
    	/*
    	 Bad: states[0]: basics states (CharacterState)
    	 		 [1]: 0 = not shooting, 1=shooting
    	 		 [2]: 0 = not using flashlights, 1 = using flashlights
    	 		 [3]: weapon slot;
    	 		 
    	  
    	 
    	
    	
    	 Pathfinder(the enemy)
    	 states[0] - 0 = waiting for player, 1 = attacking, 9 = dead, 10 = (and already exploded)
    	 states[1] - 1 = foldout turret, 0 = folding turret
    	 states[2] - 0 = not shooting, 1 = shooting
    	 
    	 */
    
    	// Use this for initialization
    	void Start ()
    	{
    		if(transform.tag == "Enemy")
    			transform.name = MyName;
    		
    	}
    
    	void Update ()
    	{
    		
    		//myInt = statesArrayInt;
    	}
    	
    	
    }
    

    Makes sense?
  • Yep, now! :)
    I will have to give it a try. Can this be reproduced in the editor or which platform do I have to compile for?
  • Yes, you can reproduce it using the editor. No need to do on other platform.
  • I tried to but can't reproduce this. int[] should work as before and for me, it does. I can send it as first element or as last...

    Maybe something in your code changed?
    Are all scripts still attached as expected?
    You could possibly add debug out to print the stream you send and receive.
    I'm sorry I can't help better...
Sign In or Register to comment.