Exemplo n.º 1
0
        public static NetworkBehaviour ReadNetworkBehaviour(this NetworkReader reader)
        {
            var mirageReader = reader.ToMirageReader();

            // we can't use ReadNetworkIdentity here, because we need to know if netid was 0 or not
            // if it is not 0 we need to read component index even if NI is null, or it'll fail to deserilize next part
            var netId = reader.ReadPackedUInt32();

            if (netId == 0)
            {
                return(null);
            }

            // always read index if netid is not 0
            var componentIndex = reader.ReadByte();

            var identity = FindNetworkIdentity(mirageReader.ObjectLocator, netId);

            if (identity is null)
            {
                return(null);
            }

            return(identity.NetworkBehaviours[componentIndex]);
        }
Exemplo n.º 2
0
        public static NetworkIdentity ReadNetworkIdentity(this NetworkReader reader)
        {
            var mirageReader = reader.ToMirageReader();

            var netId = reader.ReadPackedUInt32();

            if (netId == 0)
            {
                return(null);
            }

            return(FindNetworkIdentity(mirageReader.ObjectLocator, netId));
        }