コード例 #1
0
        void SendNetworkObjectPose()
        {
            NetDataWriter dataWriter = new NetDataWriter();

            foreach (string groupName in _NetworkObjectDictionary.Keys)
            {
                dataWriter.Reset();
                dataWriter.Put(NetworkDataType.UpdateObjectPose);

                int dataNum = _NetworkObjectDictionary[groupName].Count;
                dataWriter.Put(dataNum);

                foreach (var networkObject in _NetworkObjectDictionary[groupName])
                {
                    int        id       = networkObject.Key;
                    Vector3    position = networkObject.Value.transform.position;
                    Quaternion rotation = networkObject.Value.transform.rotation;

                    dataWriter.Put(id);
                    dataWriter.Put(position.x);
                    dataWriter.Put(position.y);
                    dataWriter.Put(position.z);
                    dataWriter.Put(rotation.x);
                    dataWriter.Put(rotation.y);
                    dataWriter.Put(rotation.z);
                    dataWriter.Put(rotation.w);
                }

                Debug.Log("SendNetworkObjectPose: [" + groupName + "]");
                _MultiplayerServer.SendToGroup(groupName, dataWriter);
            }
        }