Пример #1
0
 public static void WriteShortNullable(this NetworkWriter writer, short?value)
 {
     writer.WriteBool(value.HasValue);
     if (value.HasValue)
     {
         writer.WriteShort(value.Value);
     }
 }
Пример #2
0
        public static void WriteTexture2D(this NetworkWriter writer, Texture2D texture2D)
        {
            // TODO allocation protection when sending textures to server.
            //      currently can allocate 32k x 32k x 4 byte = 3.8 GB

            // support 'null' textures for [SyncVar]s etc.
            // https://github.com/vis2k/Mirror/issues/3144
            // simply send -1 for width.
            if (texture2D == null)
            {
                writer.WriteShort(-1);
                return;
            }

            // write dimensions first so reader can create the texture with size
            // 32k x 32k short is more than enough
            writer.WriteShort((short)texture2D.width);
            writer.WriteShort((short)texture2D.height);
            writer.WriteArray(texture2D.GetPixels32());
        }
Пример #3
0
 public static void WriteInt16(this NetworkWriter writer, short value) => writer.WriteShort(value);