Beispiel #1
0
        public void Deserialize(byte[] buffer, ref int offset, ref AnimationCurve value)
        {
            // Read length
            var length = ReadInt32(buffer, ref offset);

            // Deserialize individual keyframes again
            var keys = new Keyframe[length];

            for (int i = 0; i < length; i++)
            {
                KeyframeFormatter.Deserialize(buffer, ref offset, ref keys[i]);
            }

            // Create or update the given AnimationCurve
            if (value == null)
            {
                value = new AnimationCurve(keys);
            }
            else
            {
                value.keys = keys;
            }

            // Set the wrap modes
            var wrap = default(WrapMode);

            WrapModeFormatter.Deserialize(buffer, ref offset, ref wrap);
            value.preWrapMode = wrap;

            WrapModeFormatter.Deserialize(buffer, ref offset, ref wrap);
            value.postWrapMode = wrap;
        }
Beispiel #2
0
        public void Deserialize(byte[] buffer, ref int offset, ref Gradient value)
        {
            GradientAlphaKey[] alphaKeys = value.alphaKeys;
            AlphaKeysFormatter.Deserialize(buffer, ref offset, ref alphaKeys);
            value.alphaKeys = alphaKeys;

            GradientColorKey[] colorKeys = value.colorKeys;
            ColorKeysFormatter.Deserialize(buffer, ref offset, ref colorKeys);
            value.colorKeys = colorKeys;

            var mode = value.mode;

            GradientModeFormatter.Deserialize(buffer, ref offset, ref mode);
            value.mode = mode;
        }
Beispiel #3
0
        public void Deserialize(byte[] buffer, ref int offset, ref Keyframe value)
        {
            value.value = ReadFloat32Fixed(buffer, ref offset);
            value.time  = ReadFloat32Fixed(buffer, ref offset);

            value.inTangent = ReadFloat32Fixed(buffer, ref offset);
            value.inWeight  = ReadFloat32Fixed(buffer, ref offset);

            value.outTangent = ReadFloat32Fixed(buffer, ref offset);
            value.outWeight  = ReadFloat32Fixed(buffer, ref offset);

            var mode = value.weightedMode;

            WeightedModeFormatter.Deserialize(buffer, ref offset, ref mode);
            value.weightedMode = mode;
        }
Beispiel #4
0
        public TotalHits Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver)
        {
            switch (reader.GetCurrentJsonToken())
            {
            case JsonToken.BeginObject:
                var  count = 0;
                long value = -1;
                TotalHitsRelation?relation = null;
                while (reader.ReadIsInObject(ref count))
                {
                    var propertyName = reader.ReadPropertyNameSegmentRaw();
                    if (propertyName.EqualsBytes(ValueField))
                    {
                        value = reader.ReadInt64();
                    }
                    else if (propertyName.EqualsBytes(RelationField))
                    {
                        relation = RelationFormatter.Deserialize(ref reader, formatterResolver);
                    }
                    else
                    {
                        reader.ReadNextBlock();
                    }
                }

                return(new TotalHits {
                    Value = value, Relation = relation
                });

            case JsonToken.Number:
                return(new TotalHits {
                    Value = reader.ReadInt64()
                });

            default:
                reader.ReadNextBlock();
                return(null);
            }
        }