예제 #1
0
        public byte[] ToGlbBytes(SerializerTypes serializer = SerializerTypes.UniJSON)
        {
            string json;

            if (serializer == SerializerTypes.UniJSON)
            {
                var c = new JsonSchemaValidationContext(this)
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                json = JsonSchema.FromType(GetType()).Serialize(this, c);
            }
            else if (serializer == SerializerTypes.Generated)
            {
                var f = new JsonFormatter();
                f.GenSerialize(this);
                json = f.ToString().ParseAsJson().ToString("  ");
            }
            else if (serializer == SerializerTypes.JsonSerializable)
            {
                // Obsolete
                json = ToJson();
            }
            else
            {
                throw new Exception("[UniVRM Export Error] unknown serializer type");
            }

            RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, buffers[0].GetBytes()));
        }
예제 #2
0
        public static byte[] ToGlbBytes(this glTF self)
        {
            var f = new JsonFormatter();

            GltfSerializer.Serialize(f, self);

            var json = f.ToString().ParseAsJson().ToString("  ");

            self.RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, self.buffers[0].GetBytes()));
        }
예제 #3
0
        public byte[] ToGlbBytes(bool UseUniJSONSerializer = false)
        {
            string json;

            if (UseUniJSONSerializer)
            {
                json = JsonSchema.FromType(GetType()).Serialize(this);
            }
            else
            {
                json = ToJson();
            }

            RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, buffers[0].GetBytes()));
        }
예제 #4
0
        public byte[] ToGlbBytes(ArraySegment <Byte> bytes, bool UseUniJSONSerializer = false)
        {
            string json;

            if (UseUniJSONSerializer)
            {
                json = JsonSchema.FromType(GetType()).Serialize(this);
            }
            else
            {
                json = ToJson();
            }

            RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, bytes));
        }
예제 #5
0
파일: glTF.cs 프로젝트: ousttrue/RectUI
        public byte[] ToGlbBytes(ArraySegment <Byte> bytes, bool UseUniJSONSerializer = false)
        {
            string json;

            if (UseUniJSONSerializer)
            {
                var f = new JsonFormatter();
                f.Serialize(this);
                json = Encoding.UTF8.GetString(f.GetStoreBytes().ToArray());
            }
            else
            {
                json = ToJson();
            }

            RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, bytes));
        }
예제 #6
0
파일: glTF.cs 프로젝트: ulaph/UniVRM
        public byte[] ToGlbBytes(bool UseUniJSONSerializer = false)
        {
            string json;

            if (UseUniJSONSerializer)
            {
                var c = new JsonSchemaValidationContext(this)
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                json = JsonSchema.FromType(GetType()).Serialize(this, c);
            }
            else
            {
                json = ToJson();
            }

            RemoveUnusedExtensions(json);

            return(Glb.ToBytes(json, buffers[0].GetBytes()));
        }