コード例 #1
0
ファイル: ClientScene.cs プロジェクト: kelvinRosa/Mirror
        static void ApplySpawnPayload(NetworkIdentity uv, Vector3 position, byte[] payload, NetworkInstanceId netId, GameObject newGameObject)
        {
            if (!uv.gameObject.activeSelf)
            {
                uv.gameObject.SetActive(true);
            }
            uv.transform.position = position;
            if (payload != null && payload.Length > 0)
            {
                var payloadReader = new NetworkReader(payload);
                uv.OnUpdateVars(payloadReader, true);
            }
            if (newGameObject == null)
            {
                return;
            }

            newGameObject.SetActive(true);
            uv.SetNetworkInstanceId(netId);
            SetLocalObject(netId, newGameObject);

            // objects spawned as part of initial state are started on a second pass
            if (s_IsSpawnFinished)
            {
                uv.OnStartClient();
                CheckForOwner(uv);
            }
        }
コード例 #2
0
ファイル: ClientScene.cs プロジェクト: Edisonfb/Redes_aula
        static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage msg)
        {
            identity.Reset();
            identity.pendingLocalPlayer = msg.isLocalPlayer;
            identity.assetId            = msg.assetId;

            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }

            // apply local values for VR support
            identity.transform.localPosition = msg.position;
            identity.transform.localRotation = msg.rotation;
            identity.transform.localScale    = msg.scale;

            // deserialize components if any payload
            // (Count is 0 if there were no components)
            if (msg.payload.Count > 0)
            {
                NetworkReader payloadReader = new NetworkReader(msg.payload);
                identity.OnUpdateVars(payloadReader, true);
            }

            identity.netId = msg.netId;
            NetworkIdentity.spawned[msg.netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (isSpawnFinished)
            {
                identity.OnStartClient();
                CheckForLocalPlayer(identity);
            }
        }
コード例 #3
0
        static void ApplySpawnPayload(NetworkIdentity identity, Vector3 position, Quaternion rotation, Vector3 scale, byte[] payload, uint netId)
        {
            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }
            identity.transform.position   = position;
            identity.transform.rotation   = rotation;
            identity.transform.localScale = scale;
            if (payload != null && payload.Length > 0)
            {
                NetworkReader payloadReader = new NetworkReader(payload);
                identity.OnUpdateVars(payloadReader, true);
            }

            identity.netId = netId;
            NetworkIdentity.spawned[netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (s_IsSpawnFinished)
            {
                identity.isClient = true;
                identity.OnStartClient();
                CheckForOwner(identity);
            }
        }
コード例 #4
0
ファイル: ClientScene.cs プロジェクト: Zajozor/Mirror
        static void ApplySpawnPayload(NetworkIdentity identity, Vector3 position, Quaternion rotation, Vector3 scale, ArraySegment <byte> payload, uint netId)
        {
            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }

            // apply local values for VR support
            identity.transform.localPosition = position;
            identity.transform.localRotation = rotation;
            identity.transform.localScale    = scale;

            // deserialize components if any payload
            // (Count is 0 if there were no components)
            if (payload.Count > 0)
            {
                NetworkReader payloadReader = new NetworkReader(payload);
                identity.OnUpdateVars(payloadReader, true);
            }

            identity.netId = netId;
            NetworkIdentity.spawned[netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (isSpawnFinished)
            {
                identity.isClient = true;
                identity.OnStartClient();
                CheckForOwner(identity);
            }
        }
コード例 #5
0
        static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage msg)
        {
            identity.Reset();

            if (msg.assetId != Guid.Empty)
            {
                identity.assetId = msg.assetId;
            }

            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }

            // apply local values for VR support
            identity.transform.localPosition = msg.position;
            identity.transform.localRotation = msg.rotation;
            identity.transform.localScale    = msg.scale;
            identity.hasAuthority            = msg.isOwner;
            identity.netId = msg.netId;

            if (msg.isLocalPlayer)
            {
                InternalAddPlayer(identity);
            }

            // deserialize components if any payload
            // (Count is 0 if there were no components)
            if (msg.payload.Count > 0)
            {
                using (PooledNetworkReader payloadReader = NetworkReaderPool.GetReader(msg.payload))
                {
                    identity.OnUpdateVars(payloadReader, true);
                }
            }

            NetworkIdentity.spawned[msg.netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (isSpawnFinished)
            {
                identity.NotifyAuthority();
                identity.OnStartClient();
                CheckForLocalPlayer(identity);
            }
        }
コード例 #6
0
        static void ApplySpawnPayload(NetworkIdentity identity, Vector3 position, byte[] payload, uint netId)
        {
            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }
            identity.transform.position = position;
            if (payload != null && payload.Length > 0)
            {
                var payloadReader = new NetworkReader(payload);
                identity.OnUpdateVars(payloadReader, true);
            }

            identity.SetNetworkInstanceId(netId);
            NetworkIdentity.spawned[netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (s_IsSpawnFinished)
            {
                identity.EnableIsClient();
                identity.OnStartClient();
                CheckForOwner(identity);
            }
        }