Exemple #1
0
    public void onBytes(byte[] msg)
    {
        float[] data_f = new float[11];
        bool[]  data_b = new bool[4];
        char[]  data_c = new char[(msg.Length - ((sizeof(float) * 11) + (sizeof(bool) * 4))) / sizeof(char)];

        System.Buffer.BlockCopy(msg, 0, data_f, 0, sizeof(float) * 11);
        System.Buffer.BlockCopy(msg, sizeof(float) * 11, data_b, 0, sizeof(bool) * 4);
        System.Buffer.BlockCopy(msg, sizeof(float) * 11 + sizeof(bool) * 4, data_c, 0, msg.Length - (sizeof(bool) * 4 + sizeof(float) * 11));

        string sender = new string(data_c);


        if (sender != username)
        {
            GameObject remote;
            remote = GameObject.Find(sender);
            if (remote == null)
            {
                Object newRemote = Instantiate(remotePrefab, new Vector3(7.88f, 0.42f, 1f), Quaternion.identity);
                newRemote.name = sender;
            }
            else
            {
                RemotePlayer rp = remote.GetComponent <RemotePlayer>();
                rp.Set(new Vector3(data_f[0], data_f[1], data_f[2]), new Vector3(data_f[3], data_f[4], data_f[5]), new Vector3(data_f[6], data_f[7], data_f[8]), data_f[9], data_f[10], data_b[0], data_b[1]);
            }
        }
    }